Possible bug fix in Topology, have to test...

This commit is contained in:
Adam Ierymenko 2014-02-11 15:02:21 -08:00
parent 3f912eb4ad
commit 0ad84b8723

View File

@ -142,22 +142,18 @@ SharedPtr<Peer> Topology::getBestSupernode(const Address *avoid,unsigned int avo
// First look for a best supernode by comparing latencies, but exclude // First look for a best supernode by comparing latencies, but exclude
// supernodes that have not responded to direct messages in order to // supernodes that have not responded to direct messages in order to
// try to exclude any that are dead or unreachable. // try to exclude any that are dead or unreachable.
for(std::vector< SharedPtr<Peer> >::const_iterator sn=_supernodePeers.begin();sn!=_supernodePeers.end();) { for(std::vector< SharedPtr<Peer> >::const_iterator sn(_supernodePeers.begin());sn!=_supernodePeers.end();) {
// Skip explicitly avoided relays // Skip explicitly avoided relays
for(unsigned int i=0;i<avoidCount;++i) { for(unsigned int i=0;i<avoidCount;++i) {
if (avoid[i] == (*sn)->address()) { if (avoid[i] == (*sn)->address())
++sn; goto keep_searching_for_supernodes;
continue;
}
} }
// Skip possibly comatose or unreachable relays // Skip possibly comatose or unreachable relays
uint64_t lds = (*sn)->lastDirectSend(); uint64_t lds = (*sn)->lastDirectSend();
uint64_t ldr = (*sn)->lastDirectReceive(); uint64_t ldr = (*sn)->lastDirectReceive();
if ((lds)&&(lds > ldr)&&((lds - ldr) > ZT_PEER_RELAY_CONVERSATION_LATENCY_THRESHOLD)) { if ((lds)&&(lds > ldr)&&((lds - ldr) > ZT_PEER_RELAY_CONVERSATION_LATENCY_THRESHOLD))
++sn; goto keep_searching_for_supernodes;
continue;
}
if ((*sn)->hasActiveDirectPath(now)) { if ((*sn)->hasActiveDirectPath(now)) {
unsigned int l = (*sn)->latency(); unsigned int l = (*sn)->latency();
@ -173,6 +169,7 @@ SharedPtr<Peer> Topology::getBestSupernode(const Address *avoid,unsigned int avo
} }
} }
keep_searching_for_supernodes:
++sn; ++sn;
} }