Merge pull request #421 from bboreham/418_copy_connections

Avoid some deadlocks

Fixes #418
This commit is contained in:
rade committed 2015-02-25 16:23:05 +00:00
commit eafe17255b
1 file changed
+6 -1
+6 -1
View File
@@ -117,9 +117,14 @@ func deliverGossip(channel *GossipChannel, srcName PeerName, _ []byte, dec *gob.
func (c *GossipChannel) SendGossipMsg(buf []byte) {
protocolMsg := c.gossipMsg(buf)
// Copy the connections so we don't hold a lock
connections := make([]Connection, 0)
c.ourself.ForEachConnection(func(_ PeerName, conn Connection) {
conn.(ProtocolSender).SendProtocolMsg(protocolMsg)
connections = append(connections, conn)
})
for _, conn := range connections {
conn.(ProtocolSender).SendProtocolMsg(protocolMsg)
}
}
func (c *GossipChannel) gossipMsg(buf []byte) ProtocolMsg {