mirror of
https://github.com/ergochat/ergo.git
synced 2025-01-03 08:32:43 +01:00
Merge pull request #195 from slingamn/stopevent
clean up stopEvent (requires go v1.10)
This commit is contained in:
commit
04d7792ed2
@ -79,8 +79,6 @@ type ListenerWrapper struct {
|
|||||||
listener net.Listener
|
listener net.Listener
|
||||||
tlsConfig *tls.Config
|
tlsConfig *tls.Config
|
||||||
shouldStop bool
|
shouldStop bool
|
||||||
// lets the ListenerWrapper inform the server that it has stopped:
|
|
||||||
stopEvent chan bool
|
|
||||||
// protects atomic update of tlsConfig and shouldStop:
|
// protects atomic update of tlsConfig and shouldStop:
|
||||||
configMutex sync.Mutex // tier 1
|
configMutex sync.Mutex // tier 1
|
||||||
}
|
}
|
||||||
@ -364,7 +362,6 @@ func (server *Server) createListener(addr string, tlsConfig *tls.Config) *Listen
|
|||||||
listener: listener,
|
listener: listener,
|
||||||
tlsConfig: tlsConfig,
|
tlsConfig: tlsConfig,
|
||||||
shouldStop: false,
|
shouldStop: false,
|
||||||
stopEvent: make(chan bool, 1),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var shouldStop bool
|
var shouldStop bool
|
||||||
@ -395,7 +392,6 @@ func (server *Server) createListener(addr string, tlsConfig *tls.Config) *Listen
|
|||||||
|
|
||||||
if shouldStop {
|
if shouldStop {
|
||||||
listener.Close()
|
listener.Close()
|
||||||
wrapper.stopEvent <- true
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1085,8 +1081,6 @@ func (server *Server) setupListeners(config *Config) {
|
|||||||
} else {
|
} else {
|
||||||
// tell the listener it should stop by interrupting its Accept() call:
|
// tell the listener it should stop by interrupting its Accept() call:
|
||||||
currentListener.listener.Close()
|
currentListener.listener.Close()
|
||||||
// TODO(golang1.10) delete stopEvent once issue #21856 is released
|
|
||||||
<-currentListener.stopEvent
|
|
||||||
delete(server.listeners, addr)
|
delete(server.listeners, addr)
|
||||||
server.logger.Info("listeners", fmt.Sprintf("stopped listening on %s.", addr))
|
server.logger.Info("listeners", fmt.Sprintf("stopped listening on %s.", addr))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user