From 44971ca02bfdcd6e9f9453d72fa1ecd4e1620a1f Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Thu, 30 Oct 2014 12:02:40 +0100 Subject: [PATCH] fully abort query resolving if we hit more than 50 outqueries --- pdns/pdns_recursor.cc | 9 ++++++++- pdns/syncres.cc | 1 + pdns/syncres.hh | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index a6e71a007f..7cc7462fd5 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -563,7 +563,14 @@ void startDoResolve(void *p) // if there is a RecursorLua active, and it 'took' the query in preResolve, we don't launch beginResolve if(!t_pdl->get() || !(*t_pdl)->preresolve(dc->d_remote, local, dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), ret, res, &variableAnswer)) { - res = sr.beginResolve(dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), dc->d_mdp.d_qclass, ret); + try { + res = sr.beginResolve(dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), dc->d_mdp.d_qclass, ret); + } + catch(ImmediateServFailException &e) { + L<d_mdp.d_qname<<"' because: "<get()) { if(res == RCode::NoError) { diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 533adb87f6..d605573731 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -923,6 +923,7 @@ int SyncRes::doResolveAt(set nameservers, string auth, } else { s_outqueries++; d_outqueries++; + if(d_outqueries > 50) throw ImmediateServFailException("more than 50 queries sent while resolving "+qname); TryTCP: if(doTCP) { LOG(prefix<toStringWithPort() <