// 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) {
}
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);
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
{