From ff8044f0c0f0cc4016d1de654d38992a89e09d03 Mon Sep 17 00:00:00 2001 From: Joseph Henry Date: Fri, 10 Sep 2021 13:26:29 -0700 Subject: [PATCH] Improve multipath startup time --- node/Peer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/node/Peer.cpp b/node/Peer.cpp index f5d4519a4..941bd6c48 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -445,11 +445,21 @@ void Peer::tryMemorizedPath(void *tPtr,int64_t now) void Peer::performMultipathStateCheck(void *tPtr, int64_t now) { Mutex::Lock _l(_bond_m); + if (_bond) { + // Once enabled the Bond object persists, no need to update state + return; + } /** * Check for conditions required for multipath bonding and create a bond * if allowed. */ - _localMultipathSupported = ((RR->bc->inUse()) && (ZT_PROTO_VERSION > 9)); + int numAlivePaths = 0; + for(unsigned int i=0;ialive(now)) { + numAlivePaths++; + } + } + _localMultipathSupported = ((numAlivePaths >= 1) && (RR->bc->inUse()) && (ZT_PROTO_VERSION > 9)); if (_localMultipathSupported && !_bond) { if (RR->bc) { _bond = RR->bc->createTransportTriggeredBond(RR, this);