From: Fred Morcos Date: Thu, 26 Oct 2023 13:12:07 +0000 (+0200) Subject: Refactor UeberBackend::getAuth X-Git-Tag: rec-5.0.0-beta1~16^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a5d85f728ba1f67dc1ce1f4d0c3280beb6fba47;p=thirdparty%2Fpdns.git Refactor UeberBackend::getAuth --- diff --git a/pdns/ueberbackend.cc b/pdns/ueberbackend.cc index 17d8178613..e1e5a01331 100644 --- a/pdns/ueberbackend.cc +++ b/pdns/ueberbackend.cc @@ -459,17 +459,23 @@ bool UeberBackend::getAuth(const DNSName& target, const QType& qtype, SOAData* s DNSName shorter(target); vector> bestMatches(backends.size(), pair(target.wirelength() + 1, SOAData())); - do { + bool first = true; + while (first || shorter.chopOff()) { + first = false; + int zoneId{-1}; if (cachedOk && g_zoneCache.isEnabled()) { if (g_zoneCache.getEntry(shorter, zoneId)) { if (fillSOAFromZoneRecord(shorter, zoneId, soaData)) { - goto found; - } - else { - continue; + if (foundTarget(target, shorter, qtype, soaData, found)) { + return true; + } + + found = true; } + + continue; } // Zone does not exist, try again with a shorter name. @@ -484,8 +490,15 @@ bool UeberBackend::getAuth(const DNSName& target, const QType& qtype, SOAData* s if (cachedOk && (d_cache_ttl != 0 || d_negcache_ttl != 0)) { auto cacheResult = fillSOAFromCache(soaData, shorter); if (cacheResult == CacheResult::Hit) { - goto found; - } else if (cacheResult == CacheResult::NegativeMatch) { + if (foundTarget(target, shorter, qtype, soaData, found)) { + return true; + } + + found = true; + continue; + } + + if (cacheResult == CacheResult::NegativeMatch) { continue; } } @@ -523,13 +536,12 @@ bool UeberBackend::getAuth(const DNSName& target, const QType& qtype, SOAData* s } } - found: if (foundTarget(target, shorter, qtype, soaData, found)) { return true; } found = true; - } while (shorter.chopOff()); + } return found; }