Permalink
Browse files

fully abort query resolving if we hit more than 50 outqueries

  • Loading branch information...
1 parent a2081bd commit ab14b4fed2ae7cf60f3a8bc9eec1b33e6625ee6a @Habbie Habbie committed Oct 30, 2014
Showing with 16 additions and 1 deletion.
  1. +8 −1 pdns/pdns_recursor.cc
  2. +1 −0 pdns/syncres.cc
  3. +7 −0 pdns/syncres.hh
@@ -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<<Logger::Error<<"Sending SERVFAIL during resolve of '"<<dc->d_mdp.d_qname<<"' because: "<<e.reason<<endl;
+
+ res = RCode::ServFail;
+ }
if(t_pdl->get()) {
if(res == RCode::NoError) {
View
@@ -923,6 +923,7 @@ int SyncRes::doResolveAt(set<string, CIStringCompare> 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<<qname<<": using TCP with "<< remoteIP->toStringWithPort() <<endl);
View
@@ -593,6 +593,13 @@ private:
static AtomicCounter s_currentConnections; //!< total number of current TCP connections
};
+class ImmediateServFailException
+{
+public:
+ ImmediateServFailException(string r){reason=r;};
+
+ string reason; //! Print this to tell the user what went wrong
+};
struct RemoteKeeper
{

0 comments on commit ab14b4f

Please sign in to comment.