From: Otto Moerbeek Date: Wed, 23 Sep 2020 13:55:29 +0000 (+0200) Subject: Since record cache and negcache are global now no need to broadcast to all X-Git-Tag: auth-4.4.0-alpha2~66^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5410698bc72f2d79d1530dee057599d1efe90b67;p=thirdparty%2Fpdns.git Since record cache and negcache are global now no need to broadcast to all threads. --- diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index 0e9fa6d284..4cb3de9c7c 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -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 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([=]{ return pleaseWipeCache(wipe.first, wipe.second, qtype);}); - pcount+= broadcastAccFunction([=]{ return pleaseWipePacketCache(wipe.first, wipe.second, qtype);}); - countNeg+=broadcastAccFunction([=]{ return pleaseWipeAndCountNegCache(wipe.first, wipe.second);}); + count += g_recCache->doWipeCache(wipe.first, wipe.second, qtype); + pcount += broadcastAccFunction([=]{ return pleaseWipePacketCache(wipe.first, wipe.second, qtype);}); + countNeg += g_negCache->wipe(wipe.first, wipe.second); } catch (const std::exception& e) { g_log<([=]{return pleaseWipeCache(who, true, 0xffff);}); + g_recCache->doWipeCache(who, true, 0xffff); broadcastAccFunction([=]{return pleaseWipePacketCache(who, true, 0xffff);}); - broadcastAccFunction([=]{return pleaseWipeAndCountNegCache(who, true);}); + g_negCache->wipe(who, true); } catch (std::exception& e) { g_log<([=]{return pleaseWipeCache(entry, true, 0xffff);}); + g_recCache->doWipeCache(entry, true, 0xffff); broadcastAccFunction([=]{return pleaseWipePacketCache(entry, true, 0xffff);}); - broadcastAccFunction([=]{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::make(what)); lci.dsAnchors[who].insert(*ds); }); - broadcastAccFunction([=]{return pleaseWipeCache(who, true, 0xffff);}); + g_recCache->doWipeCache(who, true, 0xffff); broadcastAccFunction([=]{return pleaseWipePacketCache(who, true, 0xffff);}); - broadcastAccFunction([=]{return pleaseWipeAndCountNegCache(who, true);}); + g_negCache->wipe(who, true); g_log<([=]{return pleaseWipeCache(entry, true, 0xffff);}); + g_recCache->doWipeCache(entry, true, 0xffff); broadcastAccFunction([=]{return pleaseWipePacketCache(entry, true, 0xffff);}); - broadcastAccFunction([=]{return pleaseWipeAndCountNegCache(entry, true);}); + g_negCache->wipe(entry, true); if (!first) { first = false; removed += ","; diff --git a/pdns/recursor_cache.cc b/pdns/recursor_cache.cc index 4f209d3147..2748ea8013 100644 --- a/pdns/recursor_cache.cc +++ b/pdns/recursor_cache.cc @@ -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. */ diff --git a/pdns/reczones.cc b/pdns/reczones.cc index 4f074c7da2..87ec45732c 100644 --- a/pdns/reczones.cc +++ b/pdns/reczones.cc @@ -366,9 +366,9 @@ string reloadAuthAndForwards() } for(const auto& i : oldAndNewDomains) { - broadcastAccFunction([&]{return pleaseWipeCache(i, true, 0xffff);}); + g_recCache->doWipeCache(i, true, 0xffff); broadcastAccFunction([&]{return pleaseWipePacketCache(i, true, 0xffff);}); - broadcastAccFunction([&]{return pleaseWipeAndCountNegCache(i, true);}); + g_negCache->wipe(i, true); } broadcastFunction([=]{return pleaseUseNewSDomainsMap(newDomainMap);}); diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 8b1f1c72a5..4b61031714 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -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); diff --git a/pdns/ws-recursor.cc b/pdns/ws-recursor.cc index 83e3e43af3..9d64d12510 100644 --- a/pdns/ws-recursor.cc +++ b/pdns/ws-recursor.cc @@ -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([=]{return pleaseWipeCache(canon, subtree, 0xffff);}); + int count = g_recCache->doWipeCache(canon, true, 0xffff); count += broadcastAccFunction([=]{return pleaseWipePacketCache(canon, subtree, 0xffff);}); - count += broadcastAccFunction([=]{return pleaseWipeAndCountNegCache(canon, subtree);}); + count += g_negCache->wipe(canon, subtree); resp->setBody(Json::object { { "count", count }, { "result", "Flushed cache." }