From d5528f6e5672d41d2e409680ec13c808f3993ef9 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Fri, 8 Sep 2017 06:02:54 -0400 Subject: [PATCH] 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 --- irc/server.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/irc/server.go b/irc/server.go index e5d15175..20ca52f1 100644 --- a/irc/server.go +++ b/irc/server.go @@ -436,10 +436,12 @@ func (server *Server) Run() { case <-server.rehashSignal: server.logger.Info("rehash", "Rehashing due to SIGHUP") - err := server.rehash() - if err != nil { - server.logger.Error("rehash", fmt.Sprintln("Failed to rehash:", err.Error())) - } + go func() { + err := server.rehash() + if err != nil { + server.logger.Error("rehash", fmt.Sprintln("Failed to rehash:", err.Error())) + } + }() case conn := <-server.newConns: // check connection limits