]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Refactor UeberBackend::getAuth
authorFred Morcos <fred.morcos@open-xchange.com>
Thu, 26 Oct 2023 13:12:07 +0000 (15:12 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Sun, 29 Oct 2023 14:35:50 +0000 (15:35 +0100)
pdns/ueberbackend.cc

index 17d81786138c49d7129ff9ad6cb51d4156cc4937..e1e5a013311e0df61b915bfb695eea14ab93957b 100644 (file)
@@ -459,17 +459,23 @@ bool UeberBackend::getAuth(const DNSName& target, const QType& qtype, SOAData* s
   DNSName shorter(target);
   vector<pair<size_t, SOAData>> 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;
 }