From 0ad84b872331ec344ab35c240c97ccf4870f3896 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 11 Feb 2014 15:02:21 -0800 Subject: [PATCH] Possible bug fix in Topology, have to test... --- node/Topology.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/node/Topology.cpp b/node/Topology.cpp index a7285d334..0d12d0956 100644 --- a/node/Topology.cpp +++ b/node/Topology.cpp @@ -142,22 +142,18 @@ SharedPtr Topology::getBestSupernode(const Address *avoid,unsigned int avo // First look for a best supernode by comparing latencies, but exclude // supernodes that have not responded to direct messages in order to // try to exclude any that are dead or unreachable. - for(std::vector< SharedPtr >::const_iterator sn=_supernodePeers.begin();sn!=_supernodePeers.end();) { + for(std::vector< SharedPtr >::const_iterator sn(_supernodePeers.begin());sn!=_supernodePeers.end();) { // Skip explicitly avoided relays for(unsigned int i=0;iaddress()) { - ++sn; - continue; - } + if (avoid[i] == (*sn)->address()) + goto keep_searching_for_supernodes; } // Skip possibly comatose or unreachable relays uint64_t lds = (*sn)->lastDirectSend(); uint64_t ldr = (*sn)->lastDirectReceive(); - if ((lds)&&(lds > ldr)&&((lds - ldr) > ZT_PEER_RELAY_CONVERSATION_LATENCY_THRESHOLD)) { - ++sn; - continue; - } + if ((lds)&&(lds > ldr)&&((lds - ldr) > ZT_PEER_RELAY_CONVERSATION_LATENCY_THRESHOLD)) + goto keep_searching_for_supernodes; if ((*sn)->hasActiveDirectPath(now)) { unsigned int l = (*sn)->latency(); @@ -173,6 +169,7 @@ SharedPtr Topology::getBestSupernode(const Address *avoid,unsigned int avo } } +keep_searching_for_supernodes: ++sn; }