From: Peter van Dijk Date: Thu, 8 Aug 2013 12:15:54 +0000 (+0200) Subject: deduplicate UDP answer counting X-Git-Tag: rec-3.6.0-rc1~528^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=40ad461bf8976b43da9f965952a2b477862f7144;p=thirdparty%2Fpdns.git deduplicate UDP answer counting --- diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index 66cece57a2..170dbb1b67 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -208,20 +208,10 @@ int isGuarded(char **argv) void sendout(const DNSDistributor::AnswerData &AD) { - static unsigned int &numanswered=*S.getPointer("udp-answers"); - static unsigned int &numanswered4=*S.getPointer("udp4-answers"); - static unsigned int &numanswered6=*S.getPointer("udp6-answers"); - if(!AD.A) return; N->send(AD.A); - numanswered++; - - if(AD.A->d_remote.getSocklen()==sizeof(sockaddr_in)) - numanswered4++; - else - numanswered6++; int diff=AD.A->d_dt.udiff(); avg_latency=(int)(1023*avg_latency/1024+diff/1024); @@ -239,13 +229,10 @@ void *qthread(void *number) unsigned int &numreceived=*S.getPointer("udp-queries"); unsigned int &numreceiveddo=*S.getPointer("udp-do-queries"); - unsigned int &numanswered=*S.getPointer("udp-answers"); unsigned int &numreceived4=*S.getPointer("udp4-queries"); - unsigned int &numanswered4=*S.getPointer("udp4-answers"); unsigned int &numreceived6=*S.getPointer("udp6-queries"); - unsigned int &numanswered6=*S.getPointer("udp6-answers"); int diff; bool logDNSQueries = ::arg().mustDo("log-dns-queries"); @@ -309,12 +296,6 @@ void *qthread(void *number) diff=P->d_dt.udiff(); avg_latency=(int)(0.999*avg_latency+0.001*diff); // 'EWMA' - numanswered++; - if(P->d_remote.sin4.sin_family==AF_INET) - numanswered4++; - else - numanswered6++; - continue; } diff --git a/pdns/nameserver.cc b/pdns/nameserver.cc index e7d32a27b9..db996aec38 100644 --- a/pdns/nameserver.cc +++ b/pdns/nameserver.cc @@ -242,8 +242,11 @@ ResponseStats g_rs; void UDPNameserver::send(DNSPacket *p) { const string& buffer=p->getString(); - - g_rs.submitResponse(p->qtype.getCode(), buffer.length(), true); + static unsigned int &numanswered=*S.getPointer("udp-answers"); + static unsigned int &numanswered4=*S.getPointer("udp4-answers"); + static unsigned int &numanswered6=*S.getPointer("udp6-answers"); + + g_rs.submitResponse(p->qtype.getCode(), buffer.length(), true); struct msghdr msgh; struct cmsghdr *cmsg; @@ -259,6 +262,13 @@ void UDPNameserver::send(DNSPacket *p) S.ringAccount("remotes-unauth",p->getRemote()); } + /* Count responses (total/v4/v6) and byte counts */ + numanswered++; + if(p->d_remote.sin4.sin_family==AF_INET) + numanswered4++; + else + numanswered6++; + /* Set up iov and msgh structures. */ memset(&msgh, 0, sizeof(struct msghdr)); iov.iov_base = (void*)buffer.c_str();