Skip to content

Commit

Permalink
Fix condition where active-backup would fail to engage
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-henry committed Mar 14, 2024
1 parent 6be0e67 commit 3ed6379
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions node/Bond.cpp
Expand Up @@ -1094,6 +1094,7 @@ void Bond::curateBond(int64_t now, bool rebuildBond)
* Curate the set of paths that are part of the bond proper. Select a set of paths
* per logical link according to eligibility and user-specified constraints.
*/
int updatedBondedPathCount = 0;
if ((_policy == ZT_BOND_POLICY_BALANCE_RR) || (_policy == ZT_BOND_POLICY_BALANCE_XOR) || (_policy == ZT_BOND_POLICY_BALANCE_AWARE)) {
if (! _numBondedPaths) {
rebuildBond = true;
Expand All @@ -1105,7 +1106,6 @@ void Bond::curateBond(int64_t now, bool rebuildBond)
_paths[i].bonded = false;
}

int updatedBondedPathCount = 0;
// Build map associating paths with local physical links. Will be selected from in next step
std::map<SharedPtr<Link>, std::vector<int> > linkMap;
for (int i = 0; i < ZT_MAX_PEER_NETWORK_PATHS; ++i) {
Expand Down Expand Up @@ -1207,6 +1207,14 @@ void Bond::curateBond(int64_t now, bool rebuildBond)
}
}
}
if (_policy == ZT_BOND_POLICY_ACTIVE_BACKUP) {
for (int i = 0; i < ZT_MAX_PEER_NETWORK_PATHS; ++i) {
if (_paths[i].p && _paths[i].bonded) {
updatedBondedPathCount++;
}
}
_numBondedPaths = updatedBondedPathCount;
}
}

void Bond::estimatePathQuality(int64_t now)
Expand Down Expand Up @@ -1678,7 +1686,7 @@ void Bond::processActiveBackupTasks(void* tPtr, int64_t now)
if (! bFoundPathInQueue) {
_abFailoverQueue.push_front(i);
log("add link %s to failover queue (%zu links in queue)", pathToStr(_paths[i].p).c_str(), _abFailoverQueue.size());
addPathToBond(0, i);
addPathToBond(i, 0);
}
}
}
Expand Down Expand Up @@ -1728,7 +1736,7 @@ void Bond::processActiveBackupTasks(void* tPtr, int64_t now)
if (! bFoundPathInQueue) {
_abFailoverQueue.push_front(i);
log("add link %s to failover queue (%zu links in queue)", pathToStr(_paths[i].p).c_str(), _abFailoverQueue.size());
addPathToBond(0, i);
addPathToBond(i, 0);
}
}
}
Expand Down

0 comments on commit 3ed6379

Please sign in to comment.