]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: In `Bind2Backend::lookup()`, use the `zoneId` when we have it 4754/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 26 Oct 2016 13:42:27 +0000 (15:42 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 12 Dec 2016 08:40:14 +0000 (09:40 +0100)
After the initial lookup corresponding to a `DNSBackend::getAuth()`,
the subsequent ones already have the `zoneId`, so use it instead of
looping on `chopOff()` again. This should be much more efficient.

(cherry picked from commit 937a66255ff05f2e754ef113833e54cc4cf2004b)

modules/bindbackend/bindbackend2.cc

index 3baf25ebb43e7e8b937bf08407d22243e5ca29dd..4f9b06fc766defa0dfff73c43dbbc3588045da6d 100644 (file)
@@ -1036,9 +1036,17 @@ void Bind2Backend::lookup(const QType &qtype, const DNSName &qname, DNSPacket *p
   bool found=false;
   BB2DomainInfo bbd;
 
-  do {
-    found = safeGetBBDomainInfo(domain, &bbd);
-  } while ((!found || (zoneId != (int)bbd.d_id && zoneId != -1)) && domain.chopOff());
+  if (zoneId != -1) {
+    found = safeGetBBDomainInfo(zoneId, &bbd);
+    if (found) {
+      domain = bbd.d_name;
+    }
+  }
+  else {
+    do {
+      found = safeGetBBDomainInfo(domain, &bbd);
+    } while (!found && domain.chopOff());
+  }
 
   if(!found) {
     if(mustlog)