From fd2d69bb236039065a221ba8c85982df2438ccee Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Sat, 11 Sep 2010 13:41:02 +0000 Subject: [PATCH] make rec_control dump-cache also dump the negative cache, so we can see what is going on git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1713 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- pdns/rec_channel_rec.cc | 24 +++++++++++++++++++++++- pdns/recursor_cache.cc | 2 +- pdns/syncres.cc | 1 - 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index aa579cc51..077e4ab3d 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -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 diff --git a/pdns/recursor_cache.cc b/pdns/recursor_cache.cc index ff7114289..7945ebc0a 100644 --- a/pdns/recursor_cache.cc +++ b/pdns/recursor_cache.cc @@ -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>(); diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 22dd54433..4b05acfc5 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -662,7 +662,6 @@ bool SyncRes::doCacheCheck(const string &qname, const QType &qtype, vector cset; bool found=false, expired=false; -- 2.40.0