From: bert hubert Date: Wed, 21 Jan 2015 11:21:38 +0000 (+0100) Subject: implement max-tot-msec wallclock time limit per query (needs docs) X-Git-Tag: rec-3.7.0-rc1~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9de3e0340fa066d4c59449e1643a1de8c343f8f2;p=thirdparty%2Fpdns.git implement max-tot-msec wallclock time limit per query (needs docs) --- 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,