From: Fred Morcos Date: Thu, 26 Oct 2023 12:31:06 +0000 (+0200) Subject: Cleanup UeberBackend::lookup X-Git-Tag: rec-5.0.0-beta1~16^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a285530bbe7a34e0c0a9b89486f18105ceb889fa;p=thirdparty%2Fpdns.git Cleanup UeberBackend::lookup --- diff --git a/pdns/ueberbackend.cc b/pdns/ueberbackend.cc index 1902d925bd..593b1757a3 100644 --- a/pdns/ueberbackend.cc +++ b/pdns/ueberbackend.cc @@ -685,7 +685,7 @@ void UeberBackend::lookup(const QType& qtype, const DNSName& qname, int zoneId, if (!d_go) { g_log << Logger::Error << "UeberBackend is blocked, waiting for 'go'" << endl; std::unique_lock l(d_mut); - d_cond.wait(l, [] { return d_go == true; }); + d_cond.wait(l, [] { return d_go; }); g_log << Logger::Error << "Broadcast received, unblocked" << endl; } @@ -697,36 +697,35 @@ void UeberBackend::lookup(const QType& qtype, const DNSName& qname, int zoneId, d_handle.zoneId = zoneId; d_handle.pkt_p = pkt_p; - if (!backends.size()) { + if (backends.empty()) { g_log << Logger::Error << "No database backends available - unable to answer questions." << endl; d_stale = true; // please recycle us! throw PDNSException("We are stale, please recycle"); } + + d_question.qtype = d_handle.qtype; + d_question.qname = qname; + d_question.zoneId = d_handle.zoneId; + + auto cacheResult = cacheHas(d_question, d_answers); + if (cacheResult == CacheResult::Miss) { // nothing + // cout<<"UeberBackend::lookup("<lookup(d_handle.qtype, d_handle.qname, d_handle.zoneId, d_handle.pkt_p); + ++(*s_backendQueries); + } + else if (cacheResult == CacheResult::NegativeMatch) { + // cout<<"UeberBackend::lookup("<lookup(d_handle.qtype, d_handle.qname, d_handle.zoneId, d_handle.pkt_p); - ++(*s_backendQueries); - } - else if (cacheResult == CacheResult::NegativeMatch) { - // cout<<"UeberBackend::lookup("<