From: Remi Gacogne Date: Wed, 17 Feb 2021 18:01:09 +0000 (+0100) Subject: dnsdist: Clean up XFR handling X-Git-Tag: dnsdist-1.6.0-alpha2~11^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df5f9e85b5c26b53543c6c7d81717d5c9d52899b;p=thirdparty%2Fpdns.git dnsdist: Clean up XFR handling --- diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index 5be27acea1..53f23ecd35 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -494,7 +494,7 @@ void IncomingTCPConnectionState::queueResponse(std::shared_ptr state, const struct timeval& now, TCPResponse&& response) { - if (!state->d_isXFR && response.d_connection && response.d_connection->isIdle()) { + if (response.d_connection && response.d_connection->isIdle()) { // if we have added a TCP Proxy Protocol payload to a connection, don't release it to the general pool yet, no one else will be able to use it anyway if (response.d_connection->canBeReused()) { auto& list = state->d_activeConnectionsToBackend.at(response.d_connection->getDS()); @@ -543,22 +543,10 @@ void IncomingTCPConnectionState::handleResponse(std::shared_ptrd_isXFR && !state->d_xfrStarted) { - /* don't bother parsing the content of the response for now */ - state->d_xfrStarted = true; - ++g_stats.responses; - ++state->d_ci.cs->responses; - if (response.d_connection->getDS()) { - ++response.d_connection->getDS()->responses; - } - } - - if (!state->d_isXFR) { - ++g_stats.responses; - ++state->d_ci.cs->responses; - if (response.d_connection->getDS()) { - ++response.d_connection->getDS()->responses; - } + ++g_stats.responses; + ++state->d_ci.cs->responses; + if (response.d_connection->getDS()) { + ++response.d_connection->getDS()->responses; } queueResponse(state, now, std::move(response)); @@ -988,14 +976,16 @@ void IncomingTCPConnectionState::notifyIOError(std::shared_ptrd_queuedResponses.empty()) { /* stop reading and send what we have */ - TCPResponse resp = std::move(state->d_queuedResponses.front()); - state->d_queuedResponses.pop_front(); - state->d_state = IncomingTCPConnectionState::State::idle; try { - queueResponse(state, now, std::move(resp)); + auto iostate = sendQueuedResponses(state, now); + + if (state->active() && iostate != IOState::Done) { + // we need to update the state right away, nobody will do that for us + state->d_ioState->update(iostate, handleIOCallback, state, iostate == IOState::NeedWrite ? state->getClientWriteTTD(now) : state->getClientReadTTD(now)); + } } catch (const std::exception& e) { - vinfolog("exception in notifyIOError: %s", e.what()); + vinfolog("Exception in notifyIOError: %s", e.what()); } } else { diff --git a/pdns/dnsdistdist/dnsdist-tcp-upstream.hh b/pdns/dnsdistdist/dnsdist-tcp-upstream.hh index c53db29f0b..49428ed055 100644 --- a/pdns/dnsdistdist/dnsdist-tcp-upstream.hh +++ b/pdns/dnsdistdist/dnsdist-tcp-upstream.hh @@ -209,7 +209,6 @@ public: State d_state{State::doingHandshake}; bool d_readingFirstQuery{true}; bool d_isXFR{false}; - bool d_xfrStarted{false}; bool d_proxyProtocolPayloadHasTLV{false}; bool d_lastIOBlocked{false}; bool d_hadErrors{false};