diff --git a/router/gossip.go b/router/gossip.go index 5c374221..1e50b707 100644 --- a/router/gossip.go +++ b/router/gossip.go @@ -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 {