From: Otto Moerbeek Date: Fri, 1 Jul 2022 11:03:29 +0000 (+0200) Subject: Make serve stale more robust by making the view of the record cache X-Git-Tag: rec-4.8.0-alpha1~24^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fe7d70f8a40aa64613c2d0a286d6639621cc77ff;p=thirdparty%2Fpdns.git Make serve stale more robust by making the view of the record cache and SyncRes consistent: remove the > 5 for the ttl test in SyncRes glue access code. Plus fix a few record cache get flags --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index b06851ceed..bebb713bd9 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -1806,8 +1806,9 @@ int SyncRes::doResolveNoQNameMinimization(const DNSName &qname, const QType qtyp const int iterations = !d_refresh && MemRecursorCache::s_maxServedStaleExtensions > 0 ? 2 : 1; for (int loop = 0; loop < iterations; loop++) { - // First try a regular resolve - d_serveStale = loop == 1; + if (loop == 1) { + d_serveStale = true; + } // When we're not on the last iteration, a timeout is not fatal const bool exceptionOnTimeout = loop == iterations - 1; @@ -2017,6 +2018,9 @@ int SyncRes::doResolveNoQNameMinimization(const DNSName &qname, const QType qtyp } LOG(prefix<= 0) { + break; + } } catch (const ImmediateServFailException&) { if (exceptionOnTimeout) { @@ -2067,6 +2071,9 @@ vector SyncRes::getAddrs(const DNSName &qname, unsigned int depth, if (d_serveStale) { flags |= MemRecursorCache::ServeStale; } + if (d_refresh) { + flags |= MemRecursorCache::Refresh; + } try { // First look for both A and AAAA in the cache res_t cset; @@ -2214,6 +2221,9 @@ void SyncRes::getBestNSFromCache(const DNSName &qname, const QType qtype, vector if (d_serveStale) { flags |= MemRecursorCache::ServeStale; } + if (d_refresh) { + flags |= MemRecursorCache::Refresh; + } do { if (cutOffDomain && (subdomain == *cutOffDomain || !subdomain.isPartOf(*cutOffDomain))) { break; @@ -2862,12 +2872,12 @@ bool SyncRes::doCacheCheck(const DNSName &qname, const DNSName& authname, bool w if (!wasForwardRecurse && d_requireAuthData) { flags |= MemRecursorCache::RequireAuth; } - if (d_refresh) { - flags |= MemRecursorCache::Refresh; - } if (d_serveStale) { flags |= MemRecursorCache::ServeStale; } + if (d_refresh) { + flags |= MemRecursorCache::Refresh; + } if(g_recCache->get(d_now.tv_sec, sqname, sqt, flags, &cset, d_cacheRemote, d_routingTag, d_doDNSSEC ? &signatures : nullptr, d_doDNSSEC ? &authorityRecs : nullptr, &d_wasVariable, &cachedState, &wasCachedAuth, nullptr, &d_fromAuthIP) > 0) { LOG(prefix<