handle terminating the libnmdc connection
--HG-- branch : nmdc-ircfrontend
This commit is contained in:
parent
07f01a1d92
commit
d2dec97259
@ -17,6 +17,7 @@ type Server struct {
|
||||
client *Client
|
||||
channel Channel // Single blessed channel
|
||||
upstreamLauncher libnmdc.HubConnectionOptions
|
||||
upstreamCloser chan struct{}
|
||||
upstream *libnmdc.HubConnection
|
||||
motd string
|
||||
}
|
||||
@ -33,6 +34,7 @@ func NewServer(name string, upstream libnmdc.HubAddress) *Server {
|
||||
Address: upstream,
|
||||
Self: *self,
|
||||
},
|
||||
upstreamCloser: make(chan struct{}, 1),
|
||||
channel: Channel{
|
||||
clientMap: make(map[string]*Client),
|
||||
modeMap: make(map[string]*ClientMode),
|
||||
@ -60,6 +62,9 @@ func (s *Server) RunClient(conn net.Conn) {
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
s.client.disconnect()
|
||||
if s.client != nil && s.client.registered {
|
||||
s.upstreamCloser <- struct{}{}
|
||||
}
|
||||
return // FIXME cleanup
|
||||
}
|
||||
continue
|
||||
@ -98,7 +103,8 @@ func (s *Server) ProtocolReadLoop_NMDC(closeChan chan struct{}) {
|
||||
for {
|
||||
select {
|
||||
case <-closeChan:
|
||||
// Need some way of deliberately shutting down a libnmdc connection...
|
||||
// Abandon the upstream connection
|
||||
s.upstream.Disconnect()
|
||||
return
|
||||
|
||||
case hubEvent := <-s.upstream.OnEvent:
|
||||
|
Loading…
Reference in New Issue
Block a user