]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Range based loop and some comments
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 3 Aug 2020 08:52:49 +0000 (10:52 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 3 Aug 2020 08:52:49 +0000 (10:52 +0200)
pdns/syncres.cc

index ce4b16206193203e3a0916d4f4a7b77eba228bee..ca7f898dc8225d45b4d2b57f27c38613824adf09 100644 (file)
@@ -1163,12 +1163,12 @@ DNSName SyncRes::getBestNSNamesFromCache(const DNSName &qname, const QType& qtyp
   getBestNSFromCache(qname, qtype, bestns, flawedNSSet, depth, beenthere);
 
   // Pick up the auth domain
-  for (auto k = bestns.cbegin(); k != bestns.cend(); ++k) {
-    const auto nsContent = getRR<NSRecordContent>(*k);
+  for (const auto& k : bestns) {
+    const auto nsContent = getRR<NSRecordContent>(k);
     if (nsContent) {
-      nsFromCacheDomain = k->d_name;
+      nsFromCacheDomain = k.d_name;
+      break;
     }
-    break;
   }
 
   if (iter != t_sstorage.domainmap->end()) {
@@ -1176,7 +1176,8 @@ DNSName SyncRes::getBestNSNamesFromCache(const DNSName &qname, const QType& qtyp
       LOG(prefix << qname << " authOrForwDomain: " << authOrForwDomain << " nsFromCacheDomain: " << nsFromCacheDomain << " isPartof: " << authOrForwDomain.isPartOf(nsFromCacheDomain) << endl);
     }
 
-    // If the forwarder is better or equal to what's found in the cache, use forwarder
+    // If the forwarder is better or equal to what's found in the cache, use forwarder. Note that name.isPartOf(name).
+    // So queries that get NS for authOrForwDomain itself go to the forwarder
     if (authOrForwDomain.isPartOf(nsFromCacheDomain)) {
       if (doLog()) {
         LOG(prefix << qname << ": using forwarder as NS" << endl);