]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Backport #9515 to 4.4.x: actually fix wipe-cache-typed 9557/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 29 Sep 2020 13:46:20 +0000 (15:46 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 29 Sep 2020 13:46:20 +0000 (15:46 +0200)
pdns/rec_channel_rec.cc
pdns/recursor_cache.cc
pdns/reczones.cc
pdns/syncres.hh
pdns/ws-recursor.cc

index b84a203f2da6e2da013082063a3971d6fe4efcd3..b92b80c94a4178ce0a34b43a8764a08834a6eca0 100644 (file)
@@ -394,11 +394,6 @@ 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(s_RC->doWipeCache(canon, subtree));
-}
-
 uint64_t* pleaseWipePacketCache(const DNSName& canon, bool subtree, uint16_t qtype)
 {
   return new uint64_t(t_packetCache->doWipePacketCache(canon, qtype, subtree));
@@ -436,7 +431,7 @@ 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);});
+      count+= s_RC->doWipeCache(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);});
     }
@@ -544,7 +539,7 @@ static string doAddNTA(T begin, T end)
       lci.negAnchors[who] = why;
       });
   try {
-    broadcastAccFunction<uint64_t>([=]{return pleaseWipeCache(who, true, 0xffff);});
+    s_RC->doWipeCache(who, true, 0xffff);
     broadcastAccFunction<uint64_t>([=]{return pleaseWipePacketCache(who, true, 0xffff);});
     broadcastAccFunction<uint64_t>([=]{return pleaseWipeAndCountNegCache(who, true);});
   }
@@ -598,7 +593,7 @@ 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);});
+      s_RC->doWipeCache(entry, true, 0xffff);
       broadcastAccFunction<uint64_t>([=]{return pleaseWipePacketCache(entry, true, 0xffff);});
       broadcastAccFunction<uint64_t>([=]{return pleaseWipeAndCountNegCache(entry, true);});
       if (!first) {
@@ -661,7 +656,7 @@ 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);});
+    s_RC->doWipeCache(who, true, 0xffff);
     broadcastAccFunction<uint64_t>([=]{return pleaseWipePacketCache(who, true, 0xffff);});
     broadcastAccFunction<uint64_t>([=]{return pleaseWipeAndCountNegCache(who, true);});
     g_log<<Logger::Warning<<endl;
@@ -708,7 +703,7 @@ 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);});
+      s_RC->doWipeCache(entry, true, 0xffff);
       broadcastAccFunction<uint64_t>([=]{return pleaseWipePacketCache(entry, true, 0xffff);});
       broadcastAccFunction<uint64_t>([=]{return pleaseWipeAndCountNegCache(entry, true);});
       if (!first) {
index 953562123f6821b505976643a8f829cb8c08588f..4f209d3147c098f40a2e9039ea36d1073954e83b 100644 (file)
@@ -412,9 +412,13 @@ size_t MemRecursorCache::doWipeCache(const DNSName& name, bool sub, uint16_t qty
     auto range = idx.equal_range(name);
     auto i = range.first;
     while (i != range.second) {
-      i = idx.erase(i);
-      count++;
-      map.d_entriesCount--;
+      if (i->d_qtype == qtype || qtype == 0xffff) {
+        i = idx.erase(i);
+        count++;
+        map.d_entriesCount--;
+      } else {
+        ++i;
+      }
     }
 
     if (qtype == 0xffff) {
index 8d2adbab98c72d8f68741015ace23f07d73af2d1..bbcf3f2a53ef8ffba6b8a1eb8b42d204c2bc39a8 100644 (file)
@@ -366,7 +366,7 @@ string reloadAuthAndForwards()
     }
 
     for(const auto& i : oldAndNewDomains) {
-      broadcastAccFunction<uint64_t>([&]{return pleaseWipeCache(i, true, 0xffff);});
+      s_RC->doWipeCache(i, true, 0xffff);
       broadcastAccFunction<uint64_t>([&]{return pleaseWipePacketCache(i, true, 0xffff);});
       broadcastAccFunction<uint64_t>([&]{return pleaseWipeAndCountNegCache(i, true);});
     }
index 95a9aace0614a9a9f2211d94183b050f5069ecbc..1d2c3a97b09a61e6058ee0a4de8a0f0af900c4b4 100644 (file)
@@ -1122,7 +1122,6 @@ 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*);
index 83e3e43af3b7f47bb97745b969e0999863ab56d5..661e8ecf826fb1e2623f47390c958e471fb5a54c 100644 (file)
@@ -382,7 +382,7 @@ 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 = s_RC->doWipeCache(canon, subtree, 0xffff);
   count += broadcastAccFunction<uint64_t>([=]{return pleaseWipePacketCache(canon, subtree, 0xffff);});
   count += broadcastAccFunction<uint64_t>([=]{return pleaseWipeAndCountNegCache(canon, subtree);});
   resp->setBody(Json::object {