From b00be096f78a8000b9c2ad5e5c2d2dd56300bc23 Mon Sep 17 00:00:00 2001 From: David Wragg Date: Sun, 29 Mar 2015 19:10:44 +0100 Subject: [PATCH] Fix returns when iterating over Connections() d5eb76f32 replaced (*Peer)ForEachConnection into (*Peer)Connections(), and consequently converted some nested functions into for loops. But the "return" statements in those nested functions were left as-was, and so exited the outer function rather than moving on to the next iteration. Fixes #497 --- router/connection_maker.go | 2 +- router/routes.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/router/connection_maker.go b/router/connection_maker.go index 61417feb..84808159 100644 --- a/router/connection_maker.go +++ b/router/connection_maker.go @@ -136,7 +136,7 @@ func (cm *ConnectionMaker) checkStateAndAttemptConnections() time.Duration { for _, conn := range peer.Connections() { otherPeer := conn.Remote().Name if otherPeer == cm.ourself.Name || ourConnectedPeers[otherPeer] { - return + continue } address := conn.RemoteTCPAddr() // try both portnumber of connection and standard port. Don't use remote side of inbound connection. diff --git a/router/routes.go b/router/routes.go index 2c99e034..3e5340eb 100644 --- a/router/routes.go +++ b/router/routes.go @@ -132,11 +132,11 @@ func (routes *Routes) calculateBroadcast() map[PeerName][]PeerName { // locking. for _, conn := range ourself.Connections() { if !conn.Established() { - return + continue } remoteName := conn.Remote().Name if _, found := reached[remoteName]; found { - return + continue } if remoteConn, found := conn.Remote().ConnectionTo(ourself.Name); found && remoteConn.Established() { hops = append(hops, remoteName)