mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-14 20:16:36 +00:00
p2p: fix unsynchronized map access during Server shutdown
removePeer can be called even after listenLoop and dialLoop have returned.
This commit is contained in:
parent
995fab2ebc
commit
b9929d289d
1 changed files with 2 additions and 0 deletions
|
|
@ -260,9 +260,11 @@ func (srv *Server) Stop() {
|
||||||
// No new peers can be added at this point because dialLoop and
|
// No new peers can be added at this point because dialLoop and
|
||||||
// listenLoop are down. It is safe to call peerWG.Wait because
|
// listenLoop are down. It is safe to call peerWG.Wait because
|
||||||
// peerWG.Add is not called outside of those loops.
|
// peerWG.Add is not called outside of those loops.
|
||||||
|
srv.lock.Lock()
|
||||||
for _, peer := range srv.peers {
|
for _, peer := range srv.peers {
|
||||||
peer.Disconnect(DiscQuitting)
|
peer.Disconnect(DiscQuitting)
|
||||||
}
|
}
|
||||||
|
srv.lock.Unlock()
|
||||||
srv.peerWG.Wait()
|
srv.peerWG.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue