]> granicus.if.org Git - pdns/commitdiff
make the negcache be cleaned by the one true unified algorithm
authorBert Hubert <bert.hubert@netherlabs.nl>
Mon, 30 Aug 2010 20:15:53 +0000 (20:15 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Mon, 30 Aug 2010 20:15:53 +0000 (20:15 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1703 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/pdns_recursor.cc
pdns/syncres.hh

index d849d597a0affd7b5901ac524d6568a9ee76e7cf..2b2b36ed41ba61bd93b6f96ca97e9246f75e563e 100644 (file)
@@ -1092,12 +1092,7 @@ try
     t_RC->doPrune(); // this function is local to a thread, so fine anyhow
     t_packetCache->doPruneTo(::arg().asNum("max-packetcache-entries") / g_numThreads);
     
-    {
-      typedef SyncRes::negcache_t::nth_index<1>::type negcache_by_ttd_index_t;
-      negcache_by_ttd_index_t& ttdindex=boost::multi_index::get<1>(t_sstorage->negcache); 
-      negcache_by_ttd_index_t::iterator i=ttdindex.lower_bound(now.tv_sec);
-      ttdindex.erase(ttdindex.begin(), i);
-    }
+    pruneCollection(t_sstorage->negcache, ::arg().asNum("max-cache-entries") / (g_numThreads * 5));
     
     if(!((cleanCounter++)%40)) {  // this is a full scan!
       time_t limit=now.tv_sec-300;
index 9d11b9dbc6f0ca99ee615e3e270d6a81c9493b5f..e3249d209848211814e1328445882ed1eea8d406 100644 (file)
@@ -29,6 +29,10 @@ struct NegCacheEntry
   QType d_qtype;
   string d_qname;
   uint32_t d_ttd;
+  uint32_t getTTD() const
+  {
+    return d_ttd;
+  }
 };
 
 
@@ -190,8 +194,6 @@ public:
     d_doEDNS0=state;
   }
 
-
-
   int asyncresolveWrapper(const ComboAddress& ip, const string& domain, int type, bool doTCP, bool sendRDQuery, struct timeval* now, LWResult* res);
   
   static void doEDNSDumpAndClose(int fd);
@@ -224,9 +226,7 @@ public:
            >,
            composite_key_compare<CIStringCompare, std::less<QType> >
        >,
-       ordered_non_unique<
-           member<NegCacheEntry, uint32_t, &NegCacheEntry::d_ttd>
-       >
+       sequenced<> 
     >
   > negcache_t;