From: Remi Gacogne Date: Fri, 29 Mar 2024 13:22:40 +0000 (+0100) Subject: dnsdist: Release incoming TCP connection right away on backend failure X-Git-Tag: rec-5.1.0-alpha1~70^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F14005%2Fhead;p=thirdparty%2Fpdns.git 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. --- 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));