Revise peer path weighting to always prioritize cluster-optimal paths.

This commit is contained in:
Adam Ierymenko 2016-04-19 09:22:51 -07:00
parent cecfa99b7b
commit 4c455876f9
6 changed files with 107 additions and 50 deletions

View file

@ -144,14 +144,17 @@ void Peer::received(
if (np < ZT_MAX_PEER_NETWORK_PATHS) {
slot = &(_paths[np++]);
} else {
uint64_t slotLRmin = 0xffffffffffffffffULL;
uint64_t slotWorstScore = 0xffffffffffffffffULL;
for(unsigned int p=0;p<ZT_MAX_PEER_NETWORK_PATHS;++p) {
if (!_paths[p].active(now)) {
slot = &(_paths[p]);
break;
} else if (_paths[p].lastReceived() <= slotLRmin) {
slotLRmin = _paths[p].lastReceived();
slot = &(_paths[p]);
} else {
const uint64_t score = _paths[p].score();
if (score <= slotWorstScore) {
slotWorstScore = score;
slot = &(_paths[p]);
}
}
}
}