]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: In `Bind2Backend::lookup()`, use the `zoneId` when we have it 4638/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 26 Oct 2016 13:42:27 +0000 (15:42 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 26 Oct 2016 14:01:52 +0000 (16:01 +0200)
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.

modules/bindbackend/bindbackend2.cc

index 53c0db16fcc74f029c38d8d116dc023934ad13fc..4eb5bda85681440d9e7bfeb2e968aa8a173ec233 100644 (file)
@@ -1033,9 +1033,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)