From 1a5d85f728ba1f67dc1ce1f4d0c3280beb6fba47 Mon Sep 17 00:00:00 2001 From: Fred Morcos Date: Thu, 26 Oct 2023 15:12:07 +0200 Subject: [PATCH] Refactor UeberBackend::getAuth --- pdns/ueberbackend.cc | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) 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; } -- 2.47.2