]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Cleanup cachecleaner.hh
authorFred Morcos <fred.morcos@open-xchange.com>
Wed, 15 Feb 2023 14:54:57 +0000 (15:54 +0100)
committerFred Morcos <fred.morcos@open-xchange.com>
Mon, 20 Feb 2023 10:22:47 +0000 (11:22 +0100)
pdns/cachecleaner.hh
pdns/dbdnsseckeeper.cc
pdns/recursordist/recpacketcache.cc

index 5f8ee29521889bb870c0f08d7adf4ab70d1d7b66..9ec8e13c22cea8bbb20b390e395b88b78957f6a7 100644 (file)
@@ -30,8 +30,8 @@
 // this function can clean any cache that has an isStale() method on its entries, a preRemoval() method and a 'sequence' index as its second index
 // the ritual is that the oldest entries are in *front* of the sequence collection, so on a hit, move an item to the end
 // and optionally, on a miss, move it to the beginning
-template <typename S, typename C, typename T>
-void pruneCollection(C& /* container */, T& collection, size_t maxCached, size_t scanFraction = 1000)
+template <typename S, typename T>
+void pruneCollection(T& collection, size_t maxCached, size_t scanFraction = 1000)
 {
   const time_t now = time(nullptr);
   size_t toTrim = 0;
@@ -47,7 +47,8 @@ void pruneCollection(C& /* container */, T& collection, size_t maxCached, size_t
   // and nuke everything that is expired
   // otherwise, scan first 5*toTrim records, and stop once we've nuked enough
   const size_t lookAt = toTrim ? 5 * toTrim : cacheSize / scanFraction;
-  size_t tried = 0, erased = 0;
+  size_t tried = 0;
+  size_t erased = 0;
 
   for (auto iter = sidx.begin(); iter != sidx.end() && tried < lookAt; ++tried) {
     if (iter->isStale(now)) {
index 30c201290f002611f799d1ebf141412bd22bcb1f..b2e201565610d663f7b4c5f3ba7b8bdfaedb4e28 100644 (file)
@@ -961,10 +961,10 @@ void DNSSECKeeper::cleanup()
 
   if(now.tv_sec - s_last_prune > (time_t)(30)) {
     {
-      pruneCollection<SequencedTag>(*this, (*s_metacache.write_lock()), s_maxEntries);
+      pruneCollection<SequencedTag>((*s_metacache.write_lock()), s_maxEntries);
     }
     {
-      pruneCollection<SequencedTag>(*this, (*s_keycache.write_lock()), s_maxEntries);
+      pruneCollection<SequencedTag>((*s_keycache.write_lock()), s_maxEntries);
     }
     s_last_prune = time(nullptr);
   }
index 6ca11910f733407b0966138467bc350cf05af76c..8756aecbfcb2d526f1675e99b08b176ed1a17cbc 100644 (file)
@@ -201,7 +201,7 @@ uint64_t RecursorPacketCache::bytes() const
 
 void RecursorPacketCache::doPruneTo(size_t maxCached)
 {
-  pruneCollection<SequencedTag>(*this, d_packetCache, maxCached);
+  pruneCollection<SequencedTag>(d_packetCache, maxCached);
 }
 
 uint64_t RecursorPacketCache::doDump(int fd)