diff options
author | Janoš Guljaš <janos@users.noreply.github.com> | 2018-07-30 17:44:17 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-07-30 17:44:17 +0800 |
commit | 8f4c4fea20da04557d94eab0acbbc681861cce15 (patch) | |
tree | c6ffac321eea89bdac9eccf2322392a1d576e013 | |
parent | d42ce0f2c1b52e26cce475e411d97165fb975577 (diff) | |
download | dexon-8f4c4fea20da04557d94eab0acbbc681861cce15.tar.gz dexon-8f4c4fea20da04557d94eab0acbbc681861cce15.tar.zst dexon-8f4c4fea20da04557d94eab0acbbc681861cce15.zip |
p2p: fix rare deadlock in Stop (#17260)
-rw-r--r-- | p2p/server.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/p2p/server.go b/p2p/server.go index cdb5b1926..8f860d8f1 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -340,8 +340,8 @@ func (srv *Server) makeSelf(listener net.Listener, ntab discoverTable) *discover // It blocks until all active connections have been closed. func (srv *Server) Stop() { srv.lock.Lock() - defer srv.lock.Unlock() if !srv.running { + srv.lock.Unlock() return } srv.running = false @@ -350,6 +350,7 @@ func (srv *Server) Stop() { srv.listener.Close() } close(srv.quit) + srv.lock.Unlock() srv.loopWG.Wait() } |