From: Chris Hofstaedtler Date: Tue, 20 Feb 2018 18:21:09 +0000 (+0100) Subject: dnsdist: account latency for responses to TCP queries X-Git-Tag: dnsdist-1.3.0~63^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f653b8dfd2610435a8a85f2165b5ed85743e1751;p=thirdparty%2Fpdns.git dnsdist: account latency for responses to TCP queries --- diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index 37c6814d8b..64d6f77519 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -378,9 +378,10 @@ void* tcpClientThread(int pipefd) } #endif handler.writeSizeAndMsg(query, dq.len, g_tcpSendTimeout); - g_stats.selfAnswered++; - continue; - } + g_stats.selfAnswered++; + doLatencyStats(0); // we're not going to measure this + continue; + } std::shared_ptr serverPool = getPool(*holders.pools, poolname); std::shared_ptr packetCache = nullptr; @@ -425,6 +426,7 @@ void* tcpClientThread(int pipefd) } #endif handler.writeSizeAndMsg(cachedResponse, cachedResponseSize, g_tcpSendTimeout); + doLatencyStats(0); // we're not going to measure this g_stats.cacheHits++; continue; } @@ -455,6 +457,9 @@ void* tcpClientThread(int pipefd) } #endif handler.writeSizeAndMsg(query, dq.len, g_tcpSendTimeout); + + // no response-only statistics counter to update. + doLatencyStats(0); // we're not going to measure this continue; } @@ -627,6 +632,7 @@ void* tcpClientThread(int pipefd) std::lock_guard lock(g_rings.respMutex); g_rings.respRing.push_back({answertime, ci.remote, qname, dq.qtype, (unsigned int)udiff, (unsigned int)responseLen, *dh, ds->remote}); } + doLatencyStats(udiff); rewrittenResponse.clear(); } diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 566e0bee49..cdece98ba8 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -179,7 +179,7 @@ struct DelayedPacket DelayPipe * g_delay = 0; -static void doLatencyStats(double udiff) +void doLatencyStats(double udiff) { if(udiff < 1000) g_stats.latency0_1++; else if(udiff < 10000) g_stats.latency1_10++; diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index d9fa51d96b..00de7b6092 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -218,6 +218,7 @@ struct DNSDistStats extern struct DNSDistStats g_stats; +void doLatencyStats(double udiff); struct StopWatch