From: Remi Gacogne Date: Sat, 29 Jun 2019 20:30:20 +0000 (+0200) Subject: dnsdist: Don't add cache hits to the response ringbuffer X-Git-Tag: dnsdist-1.4.0-rc1~74^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7363e1ec51069abc0831bedd5180aa4d26fe946c;p=pdns dnsdist: Don't add cache hits to the response ringbuffer --- diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index 06174c306..994ba9a1b 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -471,6 +471,7 @@ public: d_downstreamFailures = 0; d_state = State::readingQuerySize; d_lastIOState = IOState::Done; + d_selfGeneratedResponse = false; } boost::optional getClientReadTTD(struct timeval now) const @@ -631,6 +632,7 @@ public: bool d_firstResponsePacket{true}; bool d_isXFR{false}; bool d_xfrStarted{false}; + bool d_selfGeneratedResponse{false}; }; static void handleIOCallback(int fd, FDMultiplexer::funcparam_t& param); @@ -650,8 +652,9 @@ static void handleResponseSent(std::shared_ptr& stat return; } - if (state->d_ds) { - /* if we have no downstream server selected, this was a self-answered response */ + if (state->d_selfGeneratedResponse == false && state->d_ds) { + /* if we have no downstream server selected, this was a self-answered response + but cache hits have a selected server as well, so be careful */ struct timespec answertime; gettime(&answertime); double udiff = state->d_ids.sentTime.udiff(); @@ -827,6 +830,7 @@ static void handleQuery(std::shared_ptr& state, stru } if (result == ProcessQueryResult::SendAnswer) { + state->d_selfGeneratedResponse = true; state->d_buffer.resize(dq.len); state->d_responseBuffer = std::move(state->d_buffer); state->d_responseSize = state->d_responseBuffer.size();