mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-13 07:29:30 +01:00
execute rehash() in its own goroutine
This prevents a deadlock: 1. rehash() is executing on the main goroutine 2. it's trying to stop a listener goroutine 3. the listener goroutine needs to hand off a new connection to newConns 4. but the main goroutine is blocked by rehash() so it can't receive it
This commit is contained in:
parent
b1376d5f71
commit
d5528f6e56
@ -436,10 +436,12 @@ func (server *Server) Run() {
|
|||||||
|
|
||||||
case <-server.rehashSignal:
|
case <-server.rehashSignal:
|
||||||
server.logger.Info("rehash", "Rehashing due to SIGHUP")
|
server.logger.Info("rehash", "Rehashing due to SIGHUP")
|
||||||
err := server.rehash()
|
go func() {
|
||||||
if err != nil {
|
err := server.rehash()
|
||||||
server.logger.Error("rehash", fmt.Sprintln("Failed to rehash:", err.Error()))
|
if err != nil {
|
||||||
}
|
server.logger.Error("rehash", fmt.Sprintln("Failed to rehash:", err.Error()))
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
case conn := <-server.newConns:
|
case conn := <-server.newConns:
|
||||||
// check connection limits
|
// check connection limits
|
||||||
|
Loading…
Reference in New Issue
Block a user