From 19d34e95514ea175fa2c0aa7dbbe006cf6e99d77 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 2 Dec 2015 17:42:01 +0100 Subject: [PATCH] Fix stats handling for TCP queries. The previous commit tried to fix the fact that TCP queries were not correctly accounted, but did not properly handle the fact that several queries can be sent over a single connection. Responses were not properly handled either. --- pdns/dnsdist-tcp.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index a7ecd2124..48710c710 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -57,6 +57,7 @@ struct ConnectionInfo { int fd; ComboAddress remote; + ClientState* cs; }; void* tcpClientThread(int pipefd); @@ -170,6 +171,11 @@ void* tcpClientThread(int pipefd) g_rings.queryRing.push_back({now,ci.remote,qname,qtype}); } + g_stats.queries++; + if (ci.cs) { + ci.cs->queries++; + } + if(localDynBlockNMG->match(ci.remote)) { vinfolog("Query from %s dropped because of dynamic block", ci.remote.toStringWithPort()); g_stats.dynBlocked++; @@ -227,6 +233,8 @@ void* tcpClientThread(int pipefd) if(dh->qr) { // something turned it into a response if (putNonBlockingMsgLen(ci.fd, qlen, g_tcpSendTimeout)) writen2WithTimeout(ci.fd, query, rlen, g_tcpSendTimeout); + + g_stats.selfAnswered++; goto drop; } @@ -305,6 +313,8 @@ void* tcpClientThread(int pipefd) if (putNonBlockingMsgLen(ci.fd, rlen, ds->tcpSendTimeout)) writen2WithTimeout(ci.fd, answerbuffer, rlen, ds->tcpSendTimeout); + + g_stats.responses++; } } catch(...){} @@ -339,12 +349,10 @@ void* tcpAcceptorThread(void* p) try { ci=0; ci = new ConnectionInfo; + ci->cs = cs; ci->fd = -1; ci->fd = SAccept(cs->tcpFD, remote); - g_stats.queries++; - cs->queries++; - if(!acl->match(remote)) { g_stats.aclDrops++; close(ci->fd); -- 2.40.0