]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: account latency for responses to TCP queries
authorChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Tue, 20 Feb 2018 18:21:09 +0000 (19:21 +0100)
committerChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Tue, 20 Feb 2018 18:23:32 +0000 (19:23 +0100)
pdns/dnsdist-tcp.cc
pdns/dnsdist.cc
pdns/dnsdist.hh

index 37c6814d8b79c5b60cd75b686fca5c8259e65974..64d6f775190739bc7e298b4ab98e0a20b374b026 100644 (file)
@@ -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> serverPool = getPool(*holders.pools, poolname);
         std::shared_ptr<DNSDistPacketCache> 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<std::mutex> 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();
       }
index 566e0bee4919b4682a196469a093582c54a4c7ce..cdece98ba8b7c5911112e5eea86cf79ec6fb02cb 100644 (file)
@@ -179,7 +179,7 @@ struct DelayedPacket
 
 DelayPipe<DelayedPacket> * 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++;
index d9fa51d96bb64571828b1e5076b05f0e906a5e36..00de7b6092076213c03daf456d6fc86c8b9eb4c6 100644 (file)
@@ -218,6 +218,7 @@ struct DNSDistStats
 
 
 extern struct DNSDistStats g_stats;
+void doLatencyStats(double udiff);
 
 
 struct StopWatch