]> granicus.if.org Git - pdns/commitdiff
Make sure we send servfail on error
authorAki Tuomi <cmouse@desteem.org>
Fri, 26 Sep 2014 11:24:58 +0000 (14:24 +0300)
committerAki Tuomi <cmouse@desteem.org>
Fri, 13 Feb 2015 10:08:11 +0000 (12:08 +0200)
pdns/distributor.hh

index 6235ec0f681c485ca702b2e71cd97f721711ab1f..cf8e56d8bfb0bed273ffb98918de4e26b0a5c8bb 100644 (file)
@@ -218,7 +218,7 @@ template<class Answer, class Question, class Backend>void *MultiThreadDistributo
         us->d_overloaded=false;
       }
       
-      Answer *a;      
+      Answer *a; 
 
 #ifndef SMTPREDIR
       if(queuetimeout && q->d_dt.udiff()>queuetimeout*1000) {
@@ -235,12 +235,18 @@ template<class Answer, class Question, class Backend>void *MultiThreadDistributo
       catch(const PDNSException &e) {
         L<<Logger::Error<<"Backend error: "<<e.reason<<endl;
         delete b;
-        return 0;
+        a=q->replyPacket();
+        a->setRcode(RCode::ServFail);
+        S.inc("servfail-packets");
+        S.ringAccount("servfail-queries",q->qdomain);
       }
       catch(...) {
         L<<Logger::Error<<Logger::NTLog<<"Caught unknown exception in Distributor thread "<<(unsigned long)pthread_self()<<endl;
         delete b;
-        return 0;
+        a=q->replyPacket();
+        a->setRcode(RCode::ServFail);
+        S.inc("servfail-packets");
+        S.ringAccount("servfail-queries",q->qdomain);
       }
 
       AnswerData<Answer> AD;
@@ -270,13 +276,19 @@ template<class Answer, class Question, class Backend>int SingleThreadDistributor
     L<<Logger::Error<<"Backend error: "<<e.reason<<endl;
     delete b;
     b=new Backend;
-    return 0;
+    a=q->replyPacket();
+    a->setRcode(RCode::ServFail);
+    S.inc("servfail-packets");
+    S.ringAccount("servfail-queries",q->qdomain);
   }
   catch(...) {
     L<<Logger::Error<<Logger::NTLog<<"Caught unknown exception in Distributor thread "<<(unsigned long)pthread_self()<<endl;
     delete b;
     b=new Backend;
-    return 0;
+    a=q->replyPacket();
+    a->setRcode(RCode::ServFail);
+    S.inc("servfail-packets");
+    S.ringAccount("servfail-queries",q->qdomain);
   }
   AnswerData<Answer> AD;
   AD.A=a;