From: Remi Gacogne Date: Wed, 10 Aug 2022 12:55:44 +0000 (+0200) Subject: dnsdist: Do not keep the mplexer created for the initial health-check around X-Git-Tag: rec-4.8.0-alpha1~62^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e98ce2e70b34af0494c46ec9ff6ba8e012175ea3;p=thirdparty%2Fpdns.git dnsdist: Do not keep the mplexer created for the initial health-check around We do not need after that initial health-check round so it is only wasting (a very small amount of) memory and one file descriptor at that point. --- diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 55943875d9..24f25436db 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -2712,17 +2712,20 @@ int main(int argc, char** argv) checkFileDescriptorsLimits(udpBindsCount, tcpBindsCount); - auto mplexer = std::unique_ptr(FDMultiplexer::getMultiplexerSilent()); - for (auto& dss : g_dstates.getCopy()) { // it is a copy, but the internal shared_ptrs are the real deal - if (dss->d_config.availability == DownstreamState::Availability::Auto) { - dss->d_nextCheck = dss->d_config.checkInterval; - if (!queueHealthCheck(mplexer, dss, true)) { - dss->setUpStatus(false); - warnlog("Marking downstream %s as 'down'", dss->getNameWithAddr()); + { + auto states = g_dstates.getCopy(); // it is a copy, but the internal shared_ptrs are the real deal + auto mplexer = std::unique_ptr(FDMultiplexer::getMultiplexerSilent(states.size())); + for (auto& dss : states) { + if (dss->d_config.availability == DownstreamState::Availability::Auto) { + dss->d_nextCheck = dss->d_config.checkInterval; + if (!queueHealthCheck(mplexer, dss, true)) { + dss->setUpStatus(false); + warnlog("Marking downstream %s as 'down'", dss->getNameWithAddr()); + } } } + handleQueuedHealthChecks(*mplexer, true); } - handleQueuedHealthChecks(*mplexer, true); for(auto& cs : g_frontends) { if (cs->dohFrontend != nullptr) {