From: Otto Moerbeek Date: Mon, 3 Aug 2020 08:52:49 +0000 (+0200) Subject: Range based loop and some comments X-Git-Tag: rec-4.4.0-beta1~48^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58822eff158e746a3863438980adf69557a111a2;p=thirdparty%2Fpdns.git Range based loop and some comments --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index ce4b162061..ca7f898dc8 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -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(*k); + for (const auto& k : bestns) { + const auto nsContent = getRR(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);