From 937a66255ff05f2e754ef113833e54cc4cf2004b Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 26 Oct 2016 15:42:27 +0200 Subject: [PATCH] auth: In `Bind2Backend::lookup()`, use the `zoneId` when we have it 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 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/bindbackend/bindbackend2.cc b/modules/bindbackend/bindbackend2.cc index 53c0db16fc..4eb5bda856 100644 --- a/modules/bindbackend/bindbackend2.cc +++ b/modules/bindbackend/bindbackend2.cc @@ -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) -- 2.47.2