From a34f264a989e0148ec5780b2c004ee68f1d0fafc Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Tue, 21 Jun 2022 17:49:23 +0200 Subject: [PATCH] dnsdist: Only put outgoing DoH conn in the idle queue if they are idle --- pdns/dnsdistdist/dnsdist-nghttp2.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pdns/dnsdistdist/dnsdist-nghttp2.cc b/pdns/dnsdistdist/dnsdist-nghttp2.cc index 299ad929fd..4288dc95a0 100644 --- a/pdns/dnsdistdist/dnsdist-nghttp2.cc +++ b/pdns/dnsdistdist/dnsdist-nghttp2.cc @@ -466,14 +466,16 @@ void DoHConnectionToBackend::stopIO() { d_ioState->reset(); - auto shared = std::dynamic_pointer_cast(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(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); + } } } -- 2.47.2