Browse Source

[trac598_new] Generate correct answer message for the callback.

zhanglikun 14 years ago
parent
commit
d1fdfd86c9
1 changed files with 14 additions and 3 deletions
  1. 14 3
      src/lib/resolve/recursive_query.cc

+ 14 - 3
src/lib/resolve/recursive_query.cc

@@ -847,14 +847,20 @@ public:
     }
 
     virtual void lookupTimeout() {
-        callCallback(false);
+        if (!callback_called_) {
+            makeSERVFAIL();
+            callCallback(false);
+        }
         assert(outstanding_events_ > 0);
         --outstanding_events_;
         stop();
     }
 
     virtual void clientTimeout() {
-        callCallback(false);
+        if (!callback_called_) {
+            makeSERVFAIL();
+            callCallback(false);
+        }
         assert(outstanding_events_ > 0);
         --outstanding_events_;
         stop();
@@ -866,7 +872,6 @@ public:
     void callCallback(bool success) {
         if (!callback_called_) {
             callback_called_ = true;
-            isc::resolve::makeErrorMessage(answer_message_, Rcode::SERVFAIL());
             if (success) {
                 resolvercallback_->success(answer_message_);
             } else {
@@ -908,6 +913,12 @@ public:
 
         stop();
     }
+
+    // Clear the answer parts of answer_message, and set the rcode
+    // to servfail
+    void makeSERVFAIL() {
+        isc::resolve::makeErrorMessage(answer_message_, Rcode::SERVFAIL());
+    }
 };
 
 }