]> granicus.if.org Git - pdns/commitdiff
improve trace-regex and trace=fail behaviour
authorPeter van Dijk <peter.van.dijk@netherlabs.nl>
Tue, 22 Jan 2013 14:12:08 +0000 (14:12 +0000)
committerPeter van Dijk <peter.van.dijk@netherlabs.nl>
Tue, 22 Jan 2013 14:12:08 +0000 (14:12 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@3072 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/pdns_recursor.cc

index 3c4b7b73fc623721b6b7cd4b7a288e337d1da353..dbc29aa68522d3d3e15f8c5a7f93b333e20b1acf 100644 (file)
@@ -550,20 +550,25 @@ void startDoResolve(void *p)
     
     uint32_t minTTL=std::numeric_limits<uint32_t>::max();
       
-    string trace(sr.getTrace());
-    if(!trace.empty()) {
-      vector<string> lines;
-      boost::split(lines, trace, boost::is_any_of("\n"));
-      BOOST_FOREACH(const string& line, lines) {
-        if(!line.empty())
-          L<<Logger::Warning<< line << endl;
-      }
-    }
     if(res < 0) {
       pw.getHeader()->rcode=RCode::ServFail;
       // no commit here, because no record
       g_stats.servFails++;
     }
+
+    if(tracedQuery || pw.getHeader()->rcode == RCode::ServFail)
+    {
+      // log trace, if we have one
+      string trace(sr.getTrace());
+      if(!trace.empty()) {
+        vector<string> lines;
+        boost::split(lines, trace, boost::is_any_of("\n"));
+        BOOST_FOREACH(const string& line, lines) {
+          if(!line.empty())
+            L<<Logger::Warning<< line << endl;
+        }
+      }
+    }
     else {
       pw.getHeader()->rcode=res;
       updateRcodeStats(res);