]> granicus.if.org Git - pdns/commitdiff
make rec_control dump-cache also dump the negative cache, so we can see what is going on
authorBert Hubert <bert.hubert@netherlabs.nl>
Sat, 11 Sep 2010 13:41:02 +0000 (13:41 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sat, 11 Sep 2010 13:41:02 +0000 (13:41 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1713 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/rec_channel_rec.cc
pdns/recursor_cache.cc
pdns/syncres.cc

index aa579cc51e3510d949510288f9b353e285240db7..077e4ab3da4d1195b2ee7d11b034637cca73e7b9 100644 (file)
@@ -110,9 +110,31 @@ string doGetParameter(T begin, T end)
 }
 
 
+static uint64_t dumpNegCache(SyncRes::negcache_t& negcache, int fd)
+{
+  FILE* fp=fdopen(dup(fd), "w");
+  if(!fp) { // dup probably failed
+    return 0;
+  }
+  fprintf(fp, "; negcache dump from thread follows\n;\n");
+  time_t now = time(0);
+  
+  typedef SyncRes::negcache_t::nth_index<1>::type sequence_t;
+  sequence_t& sidx=negcache.get<1>();
+
+  uint64_t count=0;
+  BOOST_FOREACH(const NegCacheEntry& neg, sidx)
+  {
+    ++count;
+    fprintf(fp, "%s IN %s %d VIA %s\n", neg.d_name.c_str(), neg.d_qtype.getName().c_str(), (unsigned int) (neg.d_ttd - now), neg.d_qname.c_str());
+  }
+  fclose(fp);
+  return count;
+}
+
 static uint64_t* pleaseDump(int fd)
 {
-  return new uint64_t(t_RC->doDump(fd));
+  return new uint64_t(t_RC->doDump(fd) + dumpNegCache(t_sstorage->negcache, fd));
 }
 
 template<typename T>
index ff71142899d92ad6626000299ac6b44bfa220f07..7945ebc0a58a69d70ab39b744bdbb8c1a4a0a096 100644 (file)
@@ -327,7 +327,7 @@ uint64_t MemRecursorCache::doDump(int fd)
   if(!fp) { // dup probably failed
     return 0;
   }
-  fprintf(fp, "; dump from thread follows\n;\n");
+  fprintf(fp, "; main record cache dump from thread follows\n;\n");
   typedef cache_t::nth_index<1>::type sequence_t;
   sequence_t& sidx=d_cache.get<1>();
 
index 22dd5443372ac4072127088172e53a4151e1cfbe..4b05acfc5b5c442a9ad268712739fc7c22fc2fb1 100644 (file)
@@ -662,7 +662,6 @@ bool SyncRes::doCacheCheck(const string &qname, const QType &qtype, vector<DNSRe
     }
   }
 
-
   set<DNSResourceRecord> cset;
   bool found=false, expired=false;