Skip to content

Commit

Permalink
in router, ensure the configured timeout is installed for first conne…
Browse files Browse the repository at this point in the history
…ctions
  • Loading branch information
hoytech committed Jan 10, 2025
1 parent d910fb2 commit 85a2b87
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/apps/mesh/cmd_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,20 @@ struct Router {
try {
auto routerConfig = loadRawTaoConfig(routerConfigFile);

// connectionTimeout

uint64_t newTimeoutUs = defaultConnectionTimeoutUs;
if (routerConfig.get_object().contains("connectionTimeout")) {
newTimeoutUs = routerConfig.at("connectionTimeout").get_unsigned() * 1'000'000;
}

if (connectionTimeoutUs != newTimeoutUs) {
connectionTimeoutUs = newTimeoutUs;
LI << "Using connection timeout: " << (connectionTimeoutUs / 1'000'000) << " seconds";
}

// load streamGroups

for (const auto &[groupName, spec] : routerConfig.at("streams").get_object()) {
if (!streamGroups.contains(groupName)) {
LI << "New stream group [" << groupName << "]";
Expand All @@ -314,18 +328,6 @@ struct Router {
for (const auto &[groupName, spec] : routerConfig.at("streams").get_object()) unneededGroups.erase(groupName);
for (const auto &groupName : unneededGroups) streamGroups.erase(groupName);
}

// connectionTimeout

uint64_t newTimeoutUs = defaultConnectionTimeoutUs;
if (routerConfig.get_object().contains("connectionTimeout")) {
newTimeoutUs = routerConfig.at("connectionTimeout").get_unsigned() * 1'000'000;
}

if (connectionTimeoutUs != newTimeoutUs) {
connectionTimeoutUs = newTimeoutUs;
LI << "Using connection timeout: " << (connectionTimeoutUs / 1'000'000) << " seconds";
}
} catch (std::exception &e) {
LE << "Failed to parse router config: " << e.what();
if (!firstConfigLoadSuccess) ::exit(1);
Expand Down

0 comments on commit 85a2b87

Please sign in to comment.