From 9de3e0340fa066d4c59449e1643a1de8c343f8f2 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Wed, 21 Jan 2015 12:21:38 +0100 Subject: [PATCH] implement max-tot-msec wallclock time limit per query (needs docs) --- pdns/lwres.cc | 1 - pdns/lwres.hh | 1 + pdns/pdns_recursor.cc | 5 ++++- pdns/syncres.cc | 8 ++++++-- pdns/syncres.hh | 3 ++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pdns/lwres.cc b/pdns/lwres.cc index aa863bdffe..90b3e8a0bb 100644 --- a/pdns/lwres.cc +++ b/pdns/lwres.cc @@ -78,7 +78,6 @@ int asyncresolve(const ComboAddress& ip, const string& domain, int type, bool do lwr->d_rcode = 0; lwr->d_pingCorrect = false; lwr->d_haveEDNS = false; - int ret; DTime dt; diff --git a/pdns/lwres.hh b/pdns/lwres.hh index db9aac7084..0d43249c8f 100644 --- a/pdns/lwres.hh +++ b/pdns/lwres.hh @@ -56,6 +56,7 @@ public: class LWResult { public: + LWResult() : d_usec(0) {} typedef vector res_t; vector d_result; diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index c47440a109..d036078d88 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -737,7 +737,8 @@ void startDoResolve(void *p) if(!g_quiet) { L<getTid()<<"/"<numProcesses()<<"] answer to "<<(dc->d_mdp.d_header.rd?"":"non-rd ")<<"question '"<d_mdp.d_qname<<"|"<d_mdp.d_qtype); L<<"': "<ancount)<<" answers, "<arcount)<<" additional, took "< nameservers, string auth, s_tcpoutqueries++; d_tcpoutqueries++; } + if(s_maxtotusec && d_totUsec > s_maxtotusec) + throw ImmediateServFailException("Too much time waiting for "+qname+"|"+qtype.getName()+", timeouts: "+boost::lexical_cast(d_timeouts) +", throttles: "+boost::lexical_cast(d_throttledqueries) + ", "+lexical_cast(d_totUsec/1000)+"msec"); + if(d_pdl && d_pdl->preoutquery(*remoteIP, d_requestor, qname, qtype, lwr.d_result, resolveret)) { LOG(prefix< nameservers, string auth, if(resolveret==-3) throw ImmediateServFailException("Query killed by policy"); - + d_totUsec += lwr.d_usec; if(resolveret != 1) { if(resolveret==0) { LOG(prefix< negcache_t; typedef multi_index_container < NegCacheEntry, -- 2.47.3