From: Remi Gacogne Date: Wed, 10 Feb 2021 17:56:03 +0000 (+0100) Subject: dnsdist: No need to retry if the last IO operation failed X-Git-Tag: dnsdist-1.6.0-alpha2~11^2~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=610e1bcca85ad16e705822c5a72825adb11fd2a5;p=thirdparty%2Fpdns.git dnsdist: No need to retry if the last IO operation failed --- diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index ee44e40253..f63f8b8f82 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -762,7 +762,7 @@ void IncomingTCPConnectionState::handleIO(std::shared_ptrd_state == IncomingTCPConnectionState::State::readingProxyProtocolHeader) { + if (!wouldBlock && state->d_state == IncomingTCPConnectionState::State::readingProxyProtocolHeader) { DEBUGLOG("reading proxy protocol header"); do { iostate = state->d_handler.tryRead(state->d_buffer, state->d_currentPos, state->d_proxyProtocolNeed); @@ -806,7 +806,7 @@ void IncomingTCPConnectionState::handleIO(std::shared_ptrd_state == IncomingTCPConnectionState::State::readingQuerySize) { + if (!wouldBlock && state->d_state == IncomingTCPConnectionState::State::readingQuerySize) { DEBUGLOG("reading query size"); iostate = state->d_handler.tryRead(state->d_buffer, state->d_currentPos, sizeof(uint16_t)); if (iostate == IOState::Done) { @@ -832,7 +832,7 @@ void IncomingTCPConnectionState::handleIO(std::shared_ptrd_state == IncomingTCPConnectionState::State::readingQuery) { + if (!wouldBlock && state->d_state == IncomingTCPConnectionState::State::readingQuery) { DEBUGLOG("reading query"); iostate = state->d_handler.tryRead(state->d_buffer, state->d_currentPos, state->d_querySize); if (iostate == IOState::Done) { @@ -858,15 +858,21 @@ void IncomingTCPConnectionState::handleIO(std::shared_ptrd_state = IncomingTCPConnectionState::State::idle; iostate = sendResponse(state, now, std::move(resp)); + if (iostate != IOState::Done) { + wouldBlock = true; + } } } + else if (iostate != IOState::Done) { + wouldBlock = true; + } } else { wouldBlock = true; } } - if (state->d_state == IncomingTCPConnectionState::State::sendingResponse) { + if (!wouldBlock && state->d_state == IncomingTCPConnectionState::State::sendingResponse) { DEBUGLOG("sending response"); iostate = state->d_handler.tryWrite(state->d_currentResponse.d_buffer, state->d_currentPos, state->d_currentResponse.d_buffer.size()); if (iostate == IOState::Done) {