p2p: fix rare deadlock in Stop (#17260)
This commit is contained in:
parent
d42ce0f2c1
commit
8f4c4fea20
@ -340,8 +340,8 @@ func (srv *Server) makeSelf(listener net.Listener, ntab discoverTable) *discover
|
|||||||
// It blocks until all active connections have been closed.
|
// It blocks until all active connections have been closed.
|
||||||
func (srv *Server) Stop() {
|
func (srv *Server) Stop() {
|
||||||
srv.lock.Lock()
|
srv.lock.Lock()
|
||||||
defer srv.lock.Unlock()
|
|
||||||
if !srv.running {
|
if !srv.running {
|
||||||
|
srv.lock.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
srv.running = false
|
srv.running = false
|
||||||
@ -350,6 +350,7 @@ func (srv *Server) Stop() {
|
|||||||
srv.listener.Close()
|
srv.listener.Close()
|
||||||
}
|
}
|
||||||
close(srv.quit)
|
close(srv.quit)
|
||||||
|
srv.lock.Unlock()
|
||||||
srv.loopWG.Wait()
|
srv.loopWG.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user