From 47dc2d3b70103005959c6b3eded585774529eec3 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sun, 28 Jan 2018 14:50:15 -0800 Subject: [PATCH] server: grab the read-mutex within the main loop of the peerBootstrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A recent commit modified the mutex in the server to the read/write. In order to further reduce contention, we’ll grab the read lock when we’re examining get set of peers to ignore. --- server.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.go b/server.go index 98e05fd5..7cb527ab 100644 --- a/server.go +++ b/server.go @@ -729,13 +729,13 @@ func (s *server) peerBootstrapper(numTargetPeers uint32, // With the number of peers we need calculated, we'll // query the network bootstrappers to sample a set of // random addrs for us. - s.mu.Lock() + s.mu.RLock() ignoreList := make(map[autopilot.NodeID]struct{}) for _, peer := range s.peersByPub { nID := autopilot.NewNodeID(peer.addr.IdentityKey) ignoreList[nID] = struct{}{} } - s.mu.Unlock() + s.mu.RUnlock() peerAddrs, err := discovery.MultiSourceBootstrap( ignoreList, numNeeded*2, bootStrappers...,