|
@@ -18,9 +18,10 @@
|
|
|
|
|
|
#include <asio.hpp>
|
|
#include <asio.hpp>
|
|
|
|
|
|
-#include <asiolink/recursive_query.h>
|
|
|
|
#include <asiolink/dns_service.h>
|
|
#include <asiolink/dns_service.h>
|
|
-#include <asiolink/udp_query.h>
|
|
|
|
|
|
+#include <asiolink/io_fetch.h>
|
|
|
|
+#include <asiolink/io_service.h>
|
|
|
|
+#include <asiolink/recursive_query.h>
|
|
|
|
|
|
#include <log/dummylog.h>
|
|
#include <log/dummylog.h>
|
|
|
|
|
|
@@ -65,10 +66,10 @@ typedef std::pair<std::string, uint16_t> addr_t;
|
|
*
|
|
*
|
|
* Used by RecursiveQuery::sendQuery.
|
|
* Used by RecursiveQuery::sendQuery.
|
|
*/
|
|
*/
|
|
-class RunningQuery : public UDPQuery::Callback {
|
|
|
|
|
|
+class RunningQuery : public IOFetch::Callback {
|
|
private:
|
|
private:
|
|
// The io service to handle async calls
|
|
// The io service to handle async calls
|
|
- asio::io_service& io_;
|
|
|
|
|
|
+ IOService& io_;
|
|
|
|
|
|
// Info for (re)sending the query (the question and destination)
|
|
// Info for (re)sending the query (the question and destination)
|
|
Question question_;
|
|
Question question_;
|
|
@@ -138,22 +139,22 @@ private:
|
|
int serverIndex = rand() % uc;
|
|
int serverIndex = rand() % uc;
|
|
dlog("Sending upstream query (" + question_.toText() +
|
|
dlog("Sending upstream query (" + question_.toText() +
|
|
") to " + upstream_->at(serverIndex).first);
|
|
") to " + upstream_->at(serverIndex).first);
|
|
- UDPQuery query(io_, question_,
|
|
|
|
|
|
+ IOFetch query(IPPROTO_UDP, io_, question_,
|
|
upstream_->at(serverIndex).first,
|
|
upstream_->at(serverIndex).first,
|
|
upstream_->at(serverIndex).second, buffer_, this,
|
|
upstream_->at(serverIndex).second, buffer_, this,
|
|
query_timeout_);
|
|
query_timeout_);
|
|
++queries_out_;
|
|
++queries_out_;
|
|
- io_.post(query);
|
|
|
|
|
|
+ io_.get_io_service().post(query);
|
|
} else if (zs > 0) {
|
|
} else if (zs > 0) {
|
|
int serverIndex = rand() % zs;
|
|
int serverIndex = rand() % zs;
|
|
dlog("Sending query to zone server (" + question_.toText() +
|
|
dlog("Sending query to zone server (" + question_.toText() +
|
|
") to " + zone_servers_.at(serverIndex).first);
|
|
") to " + zone_servers_.at(serverIndex).first);
|
|
- UDPQuery query(io_, question_,
|
|
|
|
|
|
+ IOFetch query(IPPROTO_IDP, io_, question_,
|
|
zone_servers_.at(serverIndex).first,
|
|
zone_servers_.at(serverIndex).first,
|
|
zone_servers_.at(serverIndex).second, buffer_, this,
|
|
zone_servers_.at(serverIndex).second, buffer_, this,
|
|
query_timeout_);
|
|
query_timeout_);
|
|
++queries_out_;
|
|
++queries_out_;
|
|
- io_.post(query);
|
|
|
|
|
|
+ io_.get_io_service().post(query);
|
|
} else {
|
|
} else {
|
|
dlog("Error, no upstream servers to send to.");
|
|
dlog("Error, no upstream servers to send to.");
|
|
}
|
|
}
|
|
@@ -280,7 +281,7 @@ private:
|
|
}
|
|
}
|
|
|
|
|
|
public:
|
|
public:
|
|
- RunningQuery(asio::io_service& io,
|
|
|
|
|
|
+ RunningQuery(IOService& io,
|
|
const Question &question,
|
|
const Question &question,
|
|
MessagePtr answer_message,
|
|
MessagePtr answer_message,
|
|
boost::shared_ptr<AddressVector> upstream,
|
|
boost::shared_ptr<AddressVector> upstream,
|
|
@@ -299,8 +300,8 @@ public:
|
|
cname_count_(0),
|
|
cname_count_(0),
|
|
query_timeout_(query_timeout),
|
|
query_timeout_(query_timeout),
|
|
retries_(retries),
|
|
retries_(retries),
|
|
- client_timer(io),
|
|
|
|
- lookup_timer(io),
|
|
|
|
|
|
+ client_timer(io.get_io_service()),
|
|
|
|
+ lookup_timer(io.get_io_service()),
|
|
queries_out_(0),
|
|
queries_out_(0),
|
|
done_(false),
|
|
done_(false),
|
|
answer_sent_(false)
|
|
answer_sent_(false)
|
|
@@ -380,10 +381,10 @@ public:
|
|
}
|
|
}
|
|
|
|
|
|
// This function is used as callback from DNSQuery.
|
|
// This function is used as callback from DNSQuery.
|
|
- virtual void operator()(UDPQuery::Result result) {
|
|
|
|
|
|
+ virtual void operator()(IOFetch::Result result) {
|
|
// XXX is this the place for TCP retry?
|
|
// XXX is this the place for TCP retry?
|
|
--queries_out_;
|
|
--queries_out_;
|
|
- if (!done_ && result != UDPQuery::TIME_OUT) {
|
|
|
|
|
|
+ if (!done_ && result != IOFetch::TIME_OUT) {
|
|
// we got an answer
|
|
// we got an answer
|
|
Message incoming(Message::PARSE);
|
|
Message incoming(Message::PARSE);
|
|
InputBuffer ibuf(buffer_->getData(), buffer_->getLength());
|
|
InputBuffer ibuf(buffer_->getData(), buffer_->getLength());
|
|
@@ -417,7 +418,7 @@ void
|
|
RecursiveQuery::resolve(const QuestionPtr& question,
|
|
RecursiveQuery::resolve(const QuestionPtr& question,
|
|
const isc::resolve::ResolverInterface::CallbackPtr callback)
|
|
const isc::resolve::ResolverInterface::CallbackPtr callback)
|
|
{
|
|
{
|
|
- asio::io_service& io = dns_service_.get_io_service();
|
|
|
|
|
|
+ IOService& io = dns_service_.getIOService();
|
|
|
|
|
|
MessagePtr answer_message(new Message(Message::RENDER));
|
|
MessagePtr answer_message(new Message(Message::RENDER));
|
|
OutputBufferPtr buffer(new OutputBuffer(0));
|
|
OutputBufferPtr buffer(new OutputBuffer(0));
|
|
@@ -438,7 +439,7 @@ RecursiveQuery::resolve(const Question& question,
|
|
// the message should be sent via TCP or UDP, or sent initially via
|
|
// the message should be sent via TCP or UDP, or sent initially via
|
|
// UDP and then fall back to TCP on failure, but for the moment
|
|
// UDP and then fall back to TCP on failure, but for the moment
|
|
// we're only going to handle UDP.
|
|
// we're only going to handle UDP.
|
|
- asio::io_service& io = dns_service_.get_io_service();
|
|
|
|
|
|
+ IOService& io = dns_service_.getIOService();
|
|
|
|
|
|
isc::resolve::ResolverInterface::CallbackPtr crs(
|
|
isc::resolve::ResolverInterface::CallbackPtr crs(
|
|
new isc::resolve::ResolverCallbackServer(server));
|
|
new isc::resolve::ResolverCallbackServer(server));
|