]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Only log failed backend connection attempt at info on first try
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 3 May 2023 14:36:29 +0000 (16:36 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 14 Aug 2023 14:35:51 +0000 (16:35 +0200)
(cherry picked from commit 3de50c36895bc12a8555066f376e70320166c73e)

pdns/dnsdist.hh
pdns/dnsdistdist/dnsdist-backend.cc

index a26adeba9e753897f04f228f43f71016de8a2c1b..e55205599fb2e2139aa75b25d7606f7c0faed719 100644 (file)
@@ -976,7 +976,7 @@ public:
     return status;
   }
 
-  bool reconnect();
+  bool reconnect(bool initialAttempt = false);
   void waitUntilConnected();
   void hash();
   void setId(const boost::uuids::uuid& newId);
index 11f2e11f2ceb42139768ee6bca36a62c3e4d0f73..40e7033ac9224e588d1e94acbb6460726fc03bce 100644 (file)
@@ -37,7 +37,7 @@ bool DownstreamState::passCrossProtocolQuery(std::unique_ptr<CrossProtocolQuery>
   }
 }
 
-bool DownstreamState::reconnect()
+bool DownstreamState::reconnect(bool initialAttempt)
 {
   std::unique_lock<std::mutex> tl(connectLock, std::try_to_lock);
   if (!tl.owns_lock() || isStopped()) {
@@ -88,7 +88,9 @@ bool DownstreamState::reconnect()
       connected = true;
     }
     catch (const std::runtime_error& error) {
-      infolog("Error connecting to new server with address %s: %s", d_config.remote.toStringWithPort(), error.what());
+      if (initialAttempt || g_verbose) {
+        infolog("Error connecting to new server with address %s: %s", d_config.remote.toStringWithPort(), error.what());
+      }
       connected = false;
       break;
     }
@@ -286,7 +288,7 @@ void DownstreamState::connectUDPSockets()
     fd = -1;
   }
 
-  reconnect();
+  reconnect(true);
 }
 
 DownstreamState::~DownstreamState()