Merge pull request #421 from bboreham/418_copy_connections
Avoid some deadlocks Fixes #418
This commit is contained in:
commit
eafe17255b
1 file changed
+6
-1
+6
-1
@@ -117,9 +117,14 @@ func deliverGossip(channel *GossipChannel, srcName PeerName, _ []byte, dec *gob.
|
|||||||
|
|
||||||
func (c *GossipChannel) SendGossipMsg(buf []byte) {
|
func (c *GossipChannel) SendGossipMsg(buf []byte) {
|
||||||
protocolMsg := c.gossipMsg(buf)
|
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) {
|
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 {
|
func (c *GossipChannel) gossipMsg(buf []byte) ProtocolMsg {
|
||||||
|
|||||||
Reference in new issue
Block a user