From 1ceb041bc51ba950578af7974b4ce2755a98855a Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Wed, 11 Mar 2015 13:26:40 +0000 Subject: [PATCH] exclude non-established connections from broadcast routing We already excluded such connections from unicast routing. Fixes #452. --- router/routes.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/router/routes.go b/router/routes.go index f8abac18..0e109fe4 100644 --- a/router/routes.go +++ b/router/routes.go @@ -137,11 +137,17 @@ func (routes *Routes) calculateBroadcast() map[PeerName][]PeerName { routes.peers.ForEach(func(name PeerName, peer *Peer) { hops := []PeerName{} if found, reached := peer.Routes(ourself, true); found { + // This is rather similar to the inner loop on + // peer.Routes(...); the main difference is in the + // locking. ourself.ForEachConnection(func(remoteName PeerName, conn Connection) { + if !conn.Established() { + return + } if _, found := reached[remoteName]; found { return } - if _, found := conn.Remote().ConnectionTo(ourself.Name); found { + if remoteConn, found := conn.Remote().ConnectionTo(ourself.Name); found && remoteConn.Established() { hops = append(hops, remoteName) } })