Don't hold Nameserver lock over call out via isKnownPeer

This commit is contained in:
Bryan Boreham committed 2016-03-21 11:52:13 +00:00
1 parent b1ec2b788a
commit 001322751f
1 file changed
+6 -3
+6 -3
View File
@@ -204,12 +204,15 @@ func (n *Nameserver) receiveGossip(msg []byte) (mesh.GossipData, mesh.GossipData
}
n.Lock()
defer n.Unlock()
isKnownPeer := n.isKnownPeer
n.Unlock() // Don't hold the lock over call out to code elsewhere
gossip.Entries.filter(func(e *Entry) bool {
return n.isKnownPeer(e.Origin)
return isKnownPeer(e.Origin)
})
n.Lock()
defer n.Unlock()
newEntries := n.entries.merge(gossip.Entries)
if len(newEntries) > 0 {
return &GossipData{Entries: newEntries, Timestamp: now()}, &gossip, nil