]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Since record cache and negcache are global now no need to broadcast to all
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 23 Sep 2020 13:55:29 +0000 (15:55 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 23 Sep 2020 13:55:29 +0000 (15:55 +0200)
threads.

pdns/rec_channel_rec.cc
pdns/recursor_cache.cc
pdns/reczones.cc
pdns/syncres.hh
pdns/ws-recursor.cc

index 0e9fa6d2848296d25e51405e9ce1b833db900cd6..4cb3de9c7c775e665f8a27f58ff67fc454454499 100644 (file)
@@ -396,24 +396,11 @@ static string doDumpFailedServers(T begin, T end)
   return "dumped "+std::to_string(total)+" records\n";
 }
 
-uint64_t* pleaseWipeCache(const DNSName& canon, bool subtree, uint16_t qtype)
-{
-  return new uint64_t(g_recCache->doWipeCache(canon, subtree, qtype));
-}
-
 uint64_t* pleaseWipePacketCache(const DNSName& canon, bool subtree, uint16_t qtype)
 {
   return new uint64_t(t_packetCache->doWipePacketCache(canon, qtype, subtree));
 }
 
-
-uint64_t* pleaseWipeAndCountNegCache(const DNSName& canon, bool subtree)
-{
-  uint64_t ret = g_negCache->wipe(canon, subtree);
-  return new uint64_t(ret);
-}
-
-
 template<typename T>
 static string doWipeCache(T begin, T end, uint16_t qtype)
 {
@@ -438,9 +425,9 @@ static string doWipeCache(T begin, T end, uint16_t qtype)
   int count=0, pcount=0, countNeg=0;
   for (auto wipe : toWipe) {
     try {
-      count+= broadcastAccFunction<uint64_t>([=]{ return pleaseWipeCache(wipe.first, wipe.second, qtype);});
-      pcount+= broadcastAccFunction<uint64_t>([=]{ return pleaseWipePacketCache(wipe.first, wipe.second, qtype);});
-      countNeg+=broadcastAccFunction<uint64_t>([=]{ return pleaseWipeAndCountNegCache(wipe.first, wipe.second);});
+      count += g_recCache->doWipeCache(wipe.first, wipe.second, qtype);
+      pcount += broadcastAccFunction<uint64_t>([=]{ return pleaseWipePacketCache(wipe.first, wipe.second, qtype);});
+      countNeg += g_negCache->wipe(wipe.first, wipe.second);
     }
     catch (const std::exception& e) {
       g_log<<Logger::Warning<<", failed: "<<e.what()<<endl;
@@ -546,9 +533,9 @@ static string doAddNTA(T begin, T end)
       lci.negAnchors[who] = why;
       });
   try {
-    broadcastAccFunction<uint64_t>([=]{return pleaseWipeCache(who, true, 0xffff);});
+    g_recCache->doWipeCache(who, true, 0xffff);
     broadcastAccFunction<uint64_t>([=]{return pleaseWipePacketCache(who, true, 0xffff);});
-    broadcastAccFunction<uint64_t>([=]{return pleaseWipeAndCountNegCache(who, true);});
+    g_negCache->wipe(who, true);
   }
   catch (std::exception& e) {
     g_log<<Logger::Warning<<", failed: "<<e.what()<<endl;
@@ -600,9 +587,9 @@ static string doClearNTA(T begin, T end)
       g_luaconfs.modify([entry](LuaConfigItems& lci) {
                           lci.negAnchors.erase(entry);
                         });
-      broadcastAccFunction<uint64_t>([=]{return pleaseWipeCache(entry, true, 0xffff);});
+      g_recCache->doWipeCache(entry, true, 0xffff);
       broadcastAccFunction<uint64_t>([=]{return pleaseWipePacketCache(entry, true, 0xffff);});
-      broadcastAccFunction<uint64_t>([=]{return pleaseWipeAndCountNegCache(entry, true);});
+      g_negCache->wipe(entry, true);
       if (!first) {
         first = false;
         removed += ",";
@@ -663,9 +650,9 @@ static string doAddTA(T begin, T end)
       auto ds=std::dynamic_pointer_cast<DSRecordContent>(DSRecordContent::make(what));
       lci.dsAnchors[who].insert(*ds);
       });
-    broadcastAccFunction<uint64_t>([=]{return pleaseWipeCache(who, true, 0xffff);});
+    g_recCache->doWipeCache(who, true, 0xffff);
     broadcastAccFunction<uint64_t>([=]{return pleaseWipePacketCache(who, true, 0xffff);});
-    broadcastAccFunction<uint64_t>([=]{return pleaseWipeAndCountNegCache(who, true);});
+    g_negCache->wipe(who, true);
     g_log<<Logger::Warning<<endl;
     return "Added Trust Anchor for " + who.toStringRootDot() + " with data " + what + "\n";
   }
@@ -710,9 +697,9 @@ static string doClearTA(T begin, T end)
       g_luaconfs.modify([entry](LuaConfigItems& lci) {
                           lci.dsAnchors.erase(entry);
                         });
-      broadcastAccFunction<uint64_t>([=]{return pleaseWipeCache(entry, true, 0xffff);});
+      g_recCache->doWipeCache(entry, true, 0xffff);
       broadcastAccFunction<uint64_t>([=]{return pleaseWipePacketCache(entry, true, 0xffff);});
-      broadcastAccFunction<uint64_t>([=]{return pleaseWipeAndCountNegCache(entry, true);});
+      g_negCache->wipe(entry, true);
       if (!first) {
         first = false;
         removed += ",";
index 4f209d3147c098f40a2e9039ea36d1073954e83b..2748ea8013cf1db501376290997f6c7a7248fe1b 100644 (file)
@@ -386,6 +386,9 @@ void MemRecursorCache::replace(time_t now, const DNSName &qname, const QType& qt
   ce.d_records.clear();
   ce.d_records.reserve(content.size());
 
+  if (ce.d_qtype == QType::DNSKEY || ce.d_qtype == QType::SOA) {
+    maxTTD = now + 1;
+  }
   for(const auto& i : content) {
     /* Yes, we have altered the d_ttl value by adding time(nullptr) to it
        prior to calling this function, so the TTL actually holds a TTD. */
index 4f074c7da2718209e3337066661292ae6eb8d4dc..87ec45732c1014a4994feb20c861e8eacca4048b 100644 (file)
@@ -366,9 +366,9 @@ string reloadAuthAndForwards()
     }
 
     for(const auto& i : oldAndNewDomains) {
-      broadcastAccFunction<uint64_t>([&]{return pleaseWipeCache(i, true, 0xffff);});
+      g_recCache->doWipeCache(i, true, 0xffff);
       broadcastAccFunction<uint64_t>([&]{return pleaseWipePacketCache(i, true, 0xffff);});
-      broadcastAccFunction<uint64_t>([&]{return pleaseWipeAndCountNegCache(i, true);});
+      g_negCache->wipe(i, true);
     }
 
     broadcastFunction([=]{return pleaseUseNewSDomainsMap(newDomainMap);});
index 8b1f1c72a55a8a61e26245c6306bb878bc446220..4b61031714cd37d0a4b879c357f22bc3a42fa809 100644 (file)
@@ -1101,9 +1101,7 @@ uint64_t* pleaseGetConcurrentQueries();
 uint64_t* pleaseGetThrottleSize();
 uint64_t* pleaseGetPacketCacheHits();
 uint64_t* pleaseGetPacketCacheSize();
-uint64_t* pleaseWipeCache(const DNSName& canon, bool subtree=false, uint16_t qtype=0xffff);
 uint64_t* pleaseWipePacketCache(const DNSName& canon, bool subtree, uint16_t qtype=0xffff);
-uint64_t* pleaseWipeAndCountNegCache(const DNSName& canon, bool subtree=false);
 void doCarbonDump(void*);
 bool primeHints(void);
 void primeRootNSZones(bool, unsigned int depth);
index 83e3e43af3b7f47bb97745b969e0999863ab56d5..9d64d125104874b1d4b7aa36751d43c4792edd1d 100644 (file)
@@ -382,9 +382,9 @@ static void apiServerCacheFlush(HttpRequest* req, HttpResponse* resp) {
   DNSName canon = apiNameToDNSName(req->getvars["domain"]);
   bool subtree = (req->getvars.count("subtree") > 0 && req->getvars["subtree"].compare("true") == 0);
 
-  int count = broadcastAccFunction<uint64_t>([=]{return pleaseWipeCache(canon, subtree, 0xffff);});
+  int count = g_recCache->doWipeCache(canon, true, 0xffff);
   count += broadcastAccFunction<uint64_t>([=]{return pleaseWipePacketCache(canon, subtree, 0xffff);});
-  count += broadcastAccFunction<uint64_t>([=]{return pleaseWipeAndCountNegCache(canon, subtree);});
+  count += g_negCache->wipe(canon, subtree);
   resp->setBody(Json::object {
     { "count", count },
     { "result", "Flushed cache." }