From: Fred Morcos Date: Wed, 15 Feb 2023 14:54:57 +0000 (+0100) Subject: Cleanup cachecleaner.hh X-Git-Tag: dnsdist-1.8.0-rc1~3^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d739aad20694dc29c26d362f575c06cea9afd884;p=thirdparty%2Fpdns.git Cleanup cachecleaner.hh --- diff --git a/pdns/cachecleaner.hh b/pdns/cachecleaner.hh index 5f8ee29521..9ec8e13c22 100644 --- a/pdns/cachecleaner.hh +++ b/pdns/cachecleaner.hh @@ -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 -void pruneCollection(C& /* container */, T& collection, size_t maxCached, size_t scanFraction = 1000) +template +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)) { diff --git a/pdns/dbdnsseckeeper.cc b/pdns/dbdnsseckeeper.cc index 30c201290f..b2e2015656 100644 --- a/pdns/dbdnsseckeeper.cc +++ b/pdns/dbdnsseckeeper.cc @@ -961,10 +961,10 @@ void DNSSECKeeper::cleanup() if(now.tv_sec - s_last_prune > (time_t)(30)) { { - pruneCollection(*this, (*s_metacache.write_lock()), s_maxEntries); + pruneCollection((*s_metacache.write_lock()), s_maxEntries); } { - pruneCollection(*this, (*s_keycache.write_lock()), s_maxEntries); + pruneCollection((*s_keycache.write_lock()), s_maxEntries); } s_last_prune = time(nullptr); } diff --git a/pdns/recursordist/recpacketcache.cc b/pdns/recursordist/recpacketcache.cc index 6ca11910f7..8756aecbfc 100644 --- a/pdns/recursordist/recpacketcache.cc +++ b/pdns/recursordist/recpacketcache.cc @@ -201,7 +201,7 @@ uint64_t RecursorPacketCache::bytes() const void RecursorPacketCache::doPruneTo(size_t maxCached) { - pruneCollection(*this, d_packetCache, maxCached); + pruneCollection(d_packetCache, maxCached); } uint64_t RecursorPacketCache::doDump(int fd)