From a508b6a6e444a2a96fd6f8a5b485f1d635d0310c Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 25 May 2020 11:33:19 +0200 Subject: [PATCH] rec: Defer the NOD lookup until after the response has been sent If the NOD lookup is slow, for example because the destination authoritative server is down, doing the NOD lookup before the response has been sent increases the latency a lot. This commit moves the actual NOD lookup after the response has been sent, so we can still use the existing mthread (we might actually need to do a proper DNS resolution to find the target authoritative server) without keeping the client waiting. (cherry picked from commit 3bd27e4a01a3614aba3c0cf425e4ab9490318dd4) --- pdns/pdns_recursor.cc | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 18f4e5efd0..eb95325613 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1056,8 +1056,6 @@ static bool checkFrameStreamExport(LocalStateHolder& luaconfsLoc #ifdef NOD_ENABLED static bool nodCheckNewDomain(const DNSName& dname) { - static const QType qt(QType::A); - static const uint16_t qc(QClass::IN); bool ret = false; // First check the (sub)domain isn't whitelisted for NOD purposes if (!g_nodDomainWL.check(dname)) { @@ -1067,19 +1065,24 @@ static bool nodCheckNewDomain(const DNSName& dname) // This should probably log to a dedicated log file g_log<getTid()<<"/"<numProcesses()<<"] answer to "<<(dc->d_mdp.d_header.rd?"":"non-rd ")<<"question '"<d_mdp.d_qname<<"|"<d_mdp.d_qtype); g_log<<"': "<ancount)<<" answers, "<arcount)<<" additional, took "<d_mdp.d_qname); + } +#endif /* NOD_ENABLED */ + // cout<d_mdp.d_qname<<"\t"<getUsec()<<"\t"<