From b9929d289df8efd68e9226fc35b14cd5d469c6e8 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 13 Apr 2015 17:37:32 +0200 Subject: p2p: fix unsynchronized map access during Server shutdown removePeer can be called even after listenLoop and dialLoop have returned. --- p2p/server.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'p2p') 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() } -- cgit