|
@@ -158,8 +158,6 @@ RecursiveQuery::setRttRecorder(boost::shared_ptr<RttRecorder>& recorder) {
|
|
|
rtt_recorder_ = recorder;
|
|
|
}
|
|
|
|
|
|
-namespace {
|
|
|
-
|
|
|
typedef std::pair<std::string, uint16_t> addr_t;
|
|
|
|
|
|
/*
|
|
@@ -169,11 +167,11 @@ typedef std::pair<std::string, uint16_t> addr_t;
|
|
|
*
|
|
|
* Used by RecursiveQuery::sendQuery.
|
|
|
*/
|
|
|
-class RunningQuery : public IOFetch::Callback {
|
|
|
+class RunningQuery::RunningQueryImpl : public IOFetch::Callback {
|
|
|
|
|
|
class ResolverNSASCallback : public isc::nsas::AddressRequestCallback {
|
|
|
public:
|
|
|
- ResolverNSASCallback(RunningQuery* rq) : rq_(rq) {}
|
|
|
+ ResolverNSASCallback(RunningQueryImpl* rq) : rq_(rq) {}
|
|
|
|
|
|
void success(const isc::nsas::NameserverAddress& address) {
|
|
|
// Success callback, send query to found namesever
|
|
@@ -193,7 +191,7 @@ public:
|
|
|
}
|
|
|
|
|
|
private:
|
|
|
- RunningQuery* rq_;
|
|
|
+ RunningQueryImpl* rq_;
|
|
|
};
|
|
|
|
|
|
|
|
@@ -294,7 +292,7 @@ private:
|
|
|
// The moment in time we sent a query to the nameserver above.
|
|
|
struct timeval current_ns_qsent_time;
|
|
|
|
|
|
- // RunningQuery deletes itself when it is done. In order for us
|
|
|
+ // RunningQueryImpl deletes itself when it is done. In order for us
|
|
|
// to do this safely, we must make sure that there are no events
|
|
|
// that might call back to it. There are two types of events in
|
|
|
// this sense; the timers we set ourselves (lookup and client),
|
|
@@ -671,7 +669,7 @@ SERVFAIL:
|
|
|
}
|
|
|
|
|
|
public:
|
|
|
- RunningQuery(IOService& io,
|
|
|
+ RunningQueryImpl(IOService& io,
|
|
|
const Question& question,
|
|
|
MessagePtr answer_message,
|
|
|
std::pair<std::string, uint16_t>& test_server,
|
|
@@ -714,7 +712,7 @@ public:
|
|
|
lookup_timer.expires_from_now(
|
|
|
boost::posix_time::milliseconds(lookup_timeout));
|
|
|
++outstanding_events_;
|
|
|
- lookup_timer.async_wait(boost::bind(&RunningQuery::lookupTimeout, this));
|
|
|
+ lookup_timer.async_wait(boost::bind(&RunningQueryImpl::lookupTimeout, this));
|
|
|
}
|
|
|
|
|
|
// Setup the timer to send an answer (client_timeout)
|
|
@@ -722,7 +720,7 @@ public:
|
|
|
client_timer.expires_from_now(
|
|
|
boost::posix_time::milliseconds(client_timeout));
|
|
|
++outstanding_events_;
|
|
|
- client_timer.async_wait(boost::bind(&RunningQuery::clientTimeout, this));
|
|
|
+ client_timer.async_wait(boost::bind(&RunningQueryImpl::clientTimeout, this));
|
|
|
}
|
|
|
|
|
|
doLookup();
|
|
@@ -892,12 +890,12 @@ public:
|
|
|
// Clear the answer parts of answer_message, and set the rcode
|
|
|
// to servfail
|
|
|
void makeSERVFAIL() {
|
|
|
- isc::resolve::makeErrorMessage(answer_message_, Rcode::SERVFAIL());
|
|
|
+ if (answer_message_) {
|
|
|
+ isc::resolve::makeErrorMessage(answer_message_, Rcode::SERVFAIL());
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-}
|
|
|
-
|
|
|
class ForwardQuery::ForwardQueryImpl : public IOFetch::Callback {
|
|
|
private:
|
|
|
// The io service to handle async calls
|
|
@@ -930,7 +928,7 @@ private:
|
|
|
asio::deadline_timer lookup_timer;
|
|
|
|
|
|
// Make FowardQuery deletes itself safely. for more information see
|
|
|
- // the comments of outstanding_events in RunningQuery.
|
|
|
+ // the comments of outstanding_events in RunningQueryImpl.
|
|
|
size_t outstanding_events_;
|
|
|
|
|
|
// If we have a client timeout, we call back with a failure message,
|
|
@@ -1074,7 +1072,7 @@ public:
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-void
|
|
|
+RunningQuery*
|
|
|
RecursiveQuery::resolve(const QuestionPtr& question,
|
|
|
const isc::resolve::ResolverInterface::CallbackPtr callback)
|
|
|
{
|
|
@@ -1117,16 +1115,17 @@ RecursiveQuery::resolve(const QuestionPtr& question,
|
|
|
// delete itself when it is done
|
|
|
LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_TRACE, RESLIB_RECQ_CACHE_NO_FIND)
|
|
|
.arg(questionText(*question)).arg(1);
|
|
|
- new RunningQuery(io, *question, answer_message,
|
|
|
- test_server_, buffer, callback,
|
|
|
- query_timeout_, client_timeout_,
|
|
|
- lookup_timeout_, retries_, nsas_,
|
|
|
- cache_, rtt_recorder_);
|
|
|
+ return (new RunningQuery(io, *question, answer_message,
|
|
|
+ test_server_, buffer, callback,
|
|
|
+ query_timeout_, client_timeout_,
|
|
|
+ lookup_timeout_, retries_, nsas_,
|
|
|
+ cache_, rtt_recorder_));
|
|
|
}
|
|
|
}
|
|
|
+ return (NULL);
|
|
|
}
|
|
|
|
|
|
-void
|
|
|
+RunningQuery*
|
|
|
RecursiveQuery::resolve(const Question& question,
|
|
|
MessagePtr answer_message,
|
|
|
OutputBufferPtr buffer,
|
|
@@ -1179,12 +1178,13 @@ RecursiveQuery::resolve(const Question& question,
|
|
|
// delete itself when it is done
|
|
|
LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_TRACE, RESLIB_RECQ_CACHE_NO_FIND)
|
|
|
.arg(questionText(question)).arg(2);
|
|
|
- new RunningQuery(io, question, answer_message,
|
|
|
- test_server_, buffer, crs, query_timeout_,
|
|
|
- client_timeout_, lookup_timeout_, retries_,
|
|
|
- nsas_, cache_, rtt_recorder_);
|
|
|
+ return (new RunningQuery(io, question, answer_message,
|
|
|
+ test_server_, buffer, crs, query_timeout_,
|
|
|
+ client_timeout_, lookup_timeout_, retries_,
|
|
|
+ nsas_, cache_, rtt_recorder_));
|
|
|
}
|
|
|
}
|
|
|
+ return (NULL);
|
|
|
}
|
|
|
|
|
|
ForwardQuery*
|
|
@@ -1232,5 +1232,24 @@ ForwardQuery::~ForwardQuery() {
|
|
|
delete fqi_;
|
|
|
}
|
|
|
|
|
|
+RunningQuery::RunningQuery(isc::asiolink::IOService& io,
|
|
|
+ const isc::dns::Question question,
|
|
|
+ isc::dns::MessagePtr answer_message,
|
|
|
+ std::pair<std::string, uint16_t>& test_server,
|
|
|
+ isc::util::OutputBufferPtr buffer,
|
|
|
+ isc::resolve::ResolverInterface::CallbackPtr cb,
|
|
|
+ int query_timeout, int client_timeout, int lookup_timeout,
|
|
|
+ unsigned retries,
|
|
|
+ isc::nsas::NameserverAddressStore& nsas,
|
|
|
+ isc::cache::ResolverCache& cache,
|
|
|
+ boost::shared_ptr<RttRecorder>& recorder)
|
|
|
+{
|
|
|
+ rqi_ = new RunningQueryImpl(io, question, answer_message, test_server, buffer, cb, query_timeout, client_timeout, lookup_timeout, retries, nsas, cache, recorder);
|
|
|
+}
|
|
|
+
|
|
|
+RunningQuery::~RunningQuery() {
|
|
|
+ delete rqi_;
|
|
|
+}
|
|
|
+
|
|
|
} // namespace asiodns
|
|
|
} // namespace isc
|