From 3bd27e4a01a3614aba3c0cf425e4ab9490318dd4 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. --- 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 29e0c05c6b..6d4914589a 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1038,8 +1038,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)) { @@ -1049,19 +1047,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"<