]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Remove now unused shard index, we scan every shard anyway
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 3 Mar 2021 13:49:03 +0000 (14:49 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 3 Mar 2021 13:49:03 +0000 (14:49 +0100)
pdns/dnsdist-cache.cc
pdns/dnsdist-cache.hh

index 5d2d3a07ba89f1c66ff994c79dcf797117e92beb..753d241001a37bb5d9769d84b946017788ab3d41 100644 (file)
@@ -302,14 +302,14 @@ size_t DNSDistPacketCache::purgeExpired(size_t upTo, const time_t now)
   const size_t maxPerShard = upTo / d_shardCount;
 
   size_t removed = 0;
-  size_t scannedMaps = 0;
+  uint32_t shardIndex = 0;
 
   do {
-    uint32_t shardIndex = (d_expungeIndex++ % d_shardCount);
-    scannedMaps++;
+    auto& shard = d_shards.at(shardIndex);
+    ++shardIndex;
 
-    WriteLock w(&d_shards.at(shardIndex).d_lock);
-    auto& map = d_shards.at(shardIndex).d_map;
+    WriteLock w(&shard.d_lock);
+    auto& map = shard.d_map;
     if (map.size() <= maxPerShard) {
       continue;
     }
@@ -322,14 +322,14 @@ size_t DNSDistPacketCache::purgeExpired(size_t upTo, const time_t now)
       if (value.validity <= now) {
         it = map.erase(it);
         --toRemove;
-        --d_shards[shardIndex].d_entriesCount;
+        --shard.d_entriesCount;
         ++removed;
       } else {
         ++it;
       }
     }
   }
-  while (scannedMaps < d_shardCount);
+  while (shardIndex < d_shardCount);
 
   return removed;
 }
index bfbf17cfc79152de47ffdeb4acb0a1fbcd574cd0..25b1a0dd42f1e9f61c7500aab2b07ace33804b16 100644 (file)
@@ -136,7 +136,6 @@ private:
   pdns::stat_t d_ttlTooShorts{0};
 
   size_t d_maxEntries;
-  uint32_t d_expungeIndex{0};
   uint32_t d_shardCount;
   uint32_t d_maxTTL;
   uint32_t d_tempFailureTTL;