From: Remi Gacogne Date: Mon, 22 Jul 2019 08:36:57 +0000 (+0200) Subject: dnsdist: Double-check we only increment the outstanding counter once X-Git-Tag: dnsdist-1.4.0-rc1~26^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e724d52a22f8513f1fe6004489ffd84c3c22e013;p=pdns dnsdist: Double-check we only increment the outstanding counter once --- 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;