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;
}
LOG(prefix<<qname<<": failed (res="<<res<<")"<<endl);
+ if (res >= 0) {
+ break;
+ }
}
catch (const ImmediateServFailException&) {
if (exceptionOnTimeout) {
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;
if (d_serveStale) {
flags |= MemRecursorCache::ServeStale;
}
+ if (d_refresh) {
+ flags |= MemRecursorCache::Refresh;
+ }
do {
if (cutOffDomain && (subdomain == *cutOffDomain || !subdomain.isPartOf(*cutOffDomain))) {
break;
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<<sqname<<": Found cache hit for "<<sqt.toString()<<": ");