]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Check that we have more cache entries than shards
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 22 Mar 2021 13:48:13 +0000 (14:48 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 22 Mar 2021 13:48:13 +0000 (14:48 +0100)
pdns/dnsdistdist/dnsdist-lua-bindings-packetcache.cc

index b57d66062dc815a8f50573ff18e10d075944ec92..79c58d558c5ab980c4e36f97c2992bb726bbd0a7 100644 (file)
@@ -24,6 +24,7 @@
 #include <sys/types.h>
 
 #include "config.h"
+#include "dolog.hh"
 #include "dnsdist.hh"
 #include "dnsdist-lua.hh"
 
@@ -91,6 +92,12 @@ void setupLuaBindingsPacketCache(LuaContext& luaCtx)
         }
       }
 
+      if (maxEntries < numberOfShards) {
+        warnlog("The number of entries (%d) in the packet cache is smaller than the number of shards (%d), decreasing the number of shards to %d", maxEntries, numberOfShards, maxEntries);
+        g_outputBuffer += "The number of entries (" + std::to_string(maxEntries) + " in the packet cache is smaller than the number of shards (" + std::to_string(numberOfShards) + "), decreasing the number of shards to " + std::to_string(maxEntries);
+        numberOfShards = maxEntries;
+      }
+
       auto res = std::make_shared<DNSDistPacketCache>(maxEntries, maxTTL, minTTL, tempFailTTL, maxNegativeTTL, staleTTL, dontAge, numberOfShards, deferrableInsertLock, ecsParsing);
 
       res->setKeepStaleData(keepStaleData);