aboutsummaryrefslogtreecommitdiffstats
path: root/p2p
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-04-13 23:37:32 +0800
committerFelix Lange <fjl@twurst.com>2015-04-13 23:37:32 +0800
commitb9929d289df8efd68e9226fc35b14cd5d469c6e8 (patch)
treee19f8344420eb76230ca3f6d72ddaef59406161d /p2p
parent995fab2ebc3b145a1dbb85841c5241cd024362ac (diff)
downloadgo-tangerine-b9929d289df8efd68e9226fc35b14cd5d469c6e8.tar.gz
go-tangerine-b9929d289df8efd68e9226fc35b14cd5d469c6e8.tar.zst
go-tangerine-b9929d289df8efd68e9226fc35b14cd5d469c6e8.zip
p2p: fix unsynchronized map access during Server shutdown
removePeer can be called even after listenLoop and dialLoop have returned.
Diffstat (limited to 'p2p')
-rw-r--r--p2p/server.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/p2p/server.go b/p2p/server.go
index 5cd3dc2ad..61e0d71e9 100644
--- a/p2p/server.go
+++ b/p2p/server.go
@@ -260,9 +260,11 @@ func (srv *Server) Stop() {
// No new peers can be added at this point because dialLoop and
// listenLoop are down. It is safe to call peerWG.Wait because
// peerWG.Add is not called outside of those loops.
+ srv.lock.Lock()
for _, peer := range srv.peers {
peer.Disconnect(DiscQuitting)
}
+ srv.lock.Unlock()
srv.peerWG.Wait()
}