]> granicus.if.org Git - pdns/commitdiff
some more stats
authorBert Hubert <bert.hubert@netherlabs.nl>
Thu, 21 Dec 2006 09:06:46 +0000 (09:06 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Thu, 21 Dec 2006 09:06:46 +0000 (09:06 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@934 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/pdns_recursor.cc
pdns/recursor_cache.cc

index af837a2fbf2fb1c68115fbf1d159ed8ebfc2007b..41020654cf665652f7542f1b0538bdd4ba73690d 100644 (file)
@@ -843,7 +843,13 @@ void handleNewUDPQuestion(int fd, boost::any& var)
        ++g_stats.qcounter;
        uint16_t type;
        char qname[256];
-       questionExpand(data, len, qname, sizeof(qname), type);  
+        try {
+          questionExpand(data, len, qname, sizeof(qname), type);  
+        }
+        catch(exception &e)
+        {
+           throw MOADNSException(e.what());
+        }
        
        // must all be same length answers right now!
        if((type==QType::A || type==QType::AAAA) && dh->arcount==0 && dh->ancount==0 && dh->nscount ==0 && ntohs(dh->qdcount)==1 ) {
@@ -875,10 +881,16 @@ void handleNewUDPQuestion(int fd, boost::any& var)
            RDTSC(tsc2);            
            g_stats.shunted++;
            sendto(fd, data, len, 0, (struct sockaddr *)(&fromaddr), fromaddr.getSocklen());
-           cerr<<"shunted: " << (tsc2-tsc1) / 3000.0 << endl;
+//         cerr<<"shunted: " << (tsc2-tsc1) / 3000.0 << endl;
            return;
          }
        }
+       else {
+         if(type!=QType::A && type!=QType::AAAA)
+           g_stats.noShuntWrongType++;
+          else
+            g_stats.noShuntWrongQuestion++;
+        }
       slow:
        DNSComboWriter* dc = new DNSComboWriter(data, len, g_now);
        dc->setSocket(fd);
index 0750884e38d117614446c26a3f6d5c5a0e499eb1..53d66fd9dccc9e5efb3522f18e5c351c453bfc88 100644 (file)
@@ -4,6 +4,7 @@
 #include <boost/shared_ptr.hpp>
 #include "dnsrecords.hh"
 #include "arguments.hh"
+#include "syncres.hh"
 
 using namespace std;
 using namespace boost;
@@ -145,7 +146,7 @@ unsigned int MemRecursorCache::bytes()
 int MemRecursorCache::getDirect(time_t now, const char* qname, const QType& qt, uint32_t ttd[10], char* data[10], uint16_t len[10])
 {
   if(!d_cachecachevalid || Utility::strcasecmp(d_cachedqname.c_str(), qname)) {
-    cerr<<"had cache cache miss for '"<<qname<<"'"<<endl;
+//    cerr<<"had cache cache miss for '"<<qname<<"'"<<endl;
     d_cachedqname=qname;
     d_cachecache=d_cache.equal_range(tie(qname));
     d_cachecachevalid=true;
@@ -154,22 +155,30 @@ int MemRecursorCache::getDirect(time_t now, const char* qname, const QType& qt,
     ;
   //    cerr<<"had cache cache hit!"<<endl;
 
-  if(d_cachecache.first == d_cachecache.second)
+  if(d_cachecache.first == d_cachecache.second) {
+    g_stats.noShuntNoMatch++;
     return false;
+  }
 
   pair<cache_t::iterator, cache_t::iterator> range = d_cachecache;
   
   unsigned int n=0;
   for(;range.first != range.second; ++range.first) {
-    if(range.first->d_qtype == QType::CNAME) // if we see a cname, we need the whole shebang (for now)
+    if(range.first->d_qtype == QType::CNAME) { // if we see a cname, we need the whole shebang (for now)
+      g_stats.noShuntCNAME++;
       return false;
+    }
     if(range.first->d_qtype != qt.getCode())
       continue;
-    if(range.first->getTTD() < (unsigned int) now)
+    if(range.first->getTTD() < (unsigned int) now) {
+      g_stats.noShuntExpired++;
       return false;
+    }
     
-    if(range.first->d_records.empty() || range.first->d_records.size() > 9 )
+    if(range.first->d_records.empty() || range.first->d_records.size() > 9 ) {
+      g_stats.noShuntSize++;
       return false;
+    }
     
     size_t limit=range.first->d_records.size();
     n=0;
@@ -189,6 +198,8 @@ int MemRecursorCache::getDirect(time_t now, const char* qname, const QType& qt,
     else
       return false;
   }
+  if(!n)
+    g_stats.noShuntNoMatch++;
   return n;
 
 }