From e724d52a22f8513f1fe6004489ffd84c3c22e013 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 22 Jul 2019 10:36:57 +0200 Subject: [PATCH] dnsdist: Double-check we only increment the outstanding counter once --- pdns/dnsdist-tcp.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index bc87e06a0..b250004d3 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -704,7 +704,7 @@ static void sendResponse(std::shared_ptr& state, str static void handleResponse(std::shared_ptr& state, struct timeval& now) { - if (state->d_responseSize < sizeof(dnsheader)) { + if (state->d_responseSize < sizeof(dnsheader) || !state->d_ds) { return; } @@ -936,7 +936,7 @@ static void handleDownstreamIO(std::shared_ptr& stat state->d_currentPos = 0; state->d_querySentTime = now; iostate = IOState::NeedRead; - if (!state->d_isXFR) { + if (!state->d_isXFR && !state->d_outstanding) { /* don't bother with the outstanding count for XFR queries */ ++state->d_ds->outstanding; state->d_outstanding = true; @@ -1012,9 +1012,13 @@ static void handleDownstreamIO(std::shared_ptr& stat if (state->d_downstreamConnection && state->d_downstreamConnection->isFresh()) { ++state->d_downstreamFailures; } - if (state->d_outstanding && state->d_ds != nullptr) { - --state->d_ds->outstanding; + + if (state->d_outstanding) { state->d_outstanding = false; + + if (state->d_ds != nullptr) { + --state->d_ds->outstanding; + } } /* remove this FD from the IO multiplexer */ iostate = IOState::Done; -- 2.40.0