]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Only put outgoing DoH conn in the idle queue if they are idle 11713/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 21 Jun 2022 15:49:23 +0000 (17:49 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 24 Jun 2022 12:13:53 +0000 (14:13 +0200)
pdns/dnsdistdist/dnsdist-nghttp2.cc

index 299ad929fd459e4a94450f15326f08c26584df96..4288dc95a07ac0227146c695dce7c38f34381df7 100644 (file)
@@ -466,14 +466,16 @@ void DoHConnectionToBackend::stopIO()
 {
   d_ioState->reset();
 
-  auto shared = std::dynamic_pointer_cast<DoHConnectionToBackend>(shared_from_this());
-  if (!willBeReusable(false)) {
-    /* remove ourselves from the connection cache, this might mean that our
-       reference count drops to zero after that, so we need to be careful */
-    t_downstreamDoHConnectionsManager.removeDownstreamConnection(shared);
-  }
-  else {
-    t_downstreamDoHConnectionsManager.moveToIdle(shared);
+  if (isIdle()) {
+    auto shared = std::dynamic_pointer_cast<DoHConnectionToBackend>(shared_from_this());
+    if (!willBeReusable(false)) {
+      /* remove ourselves from the connection cache, this might mean that our
+         reference count drops to zero after that, so we need to be careful */
+      t_downstreamDoHConnectionsManager.removeDownstreamConnection(shared);
+    }
+    else {
+      t_downstreamDoHConnectionsManager.moveToIdle(shared);
+    }
   }
 }