]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Do not keep the mplexer created for the initial health-check around 11844/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 10 Aug 2022 12:55:44 +0000 (14:55 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 10 Aug 2022 12:55:44 +0000 (14:55 +0200)
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.

pdns/dnsdist.cc

index 55943875d9d4feaaae83bcdedd651931c3915bff..24f25436db6b855ab91722219fc4fdec2fd3275b 100644 (file)
@@ -2712,17 +2712,20 @@ int main(int argc, char** argv)
 
     checkFileDescriptorsLimits(udpBindsCount, tcpBindsCount);
 
-    auto mplexer = std::unique_ptr<FDMultiplexer>(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>(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) {