Skip to content

Commit ff8044f

Browse files
committed
Improve multipath startup time
1 parent a91c49f commit ff8044f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

node/Peer.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,21 @@ void Peer::tryMemorizedPath(void *tPtr,int64_t now)
445445
void Peer::performMultipathStateCheck(void *tPtr, int64_t now)
446446
{
447447
Mutex::Lock _l(_bond_m);
448+
if (_bond) {
449+
// Once enabled the Bond object persists, no need to update state
450+
return;
451+
}
448452
/**
449453
* Check for conditions required for multipath bonding and create a bond
450454
* if allowed.
451455
*/
452-
_localMultipathSupported = ((RR->bc->inUse()) && (ZT_PROTO_VERSION > 9));
456+
int numAlivePaths = 0;
457+
for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
458+
if (_paths[i].p && _paths[i].p->alive(now)) {
459+
numAlivePaths++;
460+
}
461+
}
462+
_localMultipathSupported = ((numAlivePaths >= 1) && (RR->bc->inUse()) && (ZT_PROTO_VERSION > 9));
453463
if (_localMultipathSupported && !_bond) {
454464
if (RR->bc) {
455465
_bond = RR->bc->createTransportTriggeredBond(RR, this);

0 commit comments

Comments
 (0)