From 5e8f7194934857b1fd579c2ad68c56523d0e5941 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 29 Mar 2024 14:22:40 +0100 Subject: [PATCH] dnsdist: Release incoming TCP connection right away on backend failure We used to keep a shared pointer to the incoming TCP connection around in `TCPConnectionToBackend::d_currentQuery.d_sender` even after all queries sent to the backend failed, which prevented the incoming TCP connection from being closed as soon as it should have. --- pdns/dnsdistdist/dnsdist-tcp-downstream.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pdns/dnsdistdist/dnsdist-tcp-downstream.cc b/pdns/dnsdistdist/dnsdist-tcp-downstream.cc index 684c46fcee..904913e3ee 100644 --- a/pdns/dnsdistdist/dnsdist-tcp-downstream.cc +++ b/pdns/dnsdistdist/dnsdist-tcp-downstream.cc @@ -608,7 +608,7 @@ void TCPConnectionToBackend::notifyAllQueriesFailed(const struct timeval& now, F try { if (d_state == State::sendingQueryToBackend) { increaseCounters(d_currentQuery.d_query.d_idstate.cs); - auto sender = d_currentQuery.d_sender; + auto sender = std::move(d_currentQuery.d_sender); if (sender->active()) { TCPResponse response(std::move(d_currentQuery.d_query)); sender->notifyIOError(now, std::move(response)); @@ -617,7 +617,7 @@ void TCPConnectionToBackend::notifyAllQueriesFailed(const struct timeval& now, F for (auto& query : pendingQueries) { increaseCounters(query.d_query.d_idstate.cs); - auto sender = query.d_sender; + auto sender = std::move(query.d_sender); if (sender->active()) { TCPResponse response(std::move(query.d_query)); sender->notifyIOError(now, std::move(response)); @@ -626,7 +626,7 @@ void TCPConnectionToBackend::notifyAllQueriesFailed(const struct timeval& now, F for (auto& response : pendingResponses) { increaseCounters(response.second.d_query.d_idstate.cs); - auto sender = response.second.d_sender; + auto sender = std::move(response.second.d_sender); if (sender->active()) { TCPResponse tresp(std::move(response.second.d_query)); sender->notifyIOError(now, std::move(tresp)); -- 2.47.2