Commit 92397738 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[trac494] remove 'Direct' callback holder

now that AbstractResolverCallback wqas removed, the 'direct' callback
holder class is not necessary anymore (callers can derive from
ResolverInterface::Callback now)
parent d8a73201
......@@ -357,7 +357,7 @@ private:
// Server to notify when we succeed or fail
//shared_ptr<DNSServer> server_;
isc::resolve::AbstractResolverCallback* resolvercallback_;
isc::resolve::ResolverInterface::CallbackPtr resolvercallback_;
/*
* TODO Do something more clever with timeouts. In the long term, some
......@@ -480,7 +480,7 @@ public:
shared_ptr<AddressVector> upstream_root,
OutputBufferPtr buffer,
//DNSServer* server,
isc::resolve::AbstractResolverCallback* cb,
isc::resolve::ResolverInterface::CallbackPtr cb,
int timeout,
unsigned retries) :
io_(io),
......@@ -566,15 +566,17 @@ RecursiveQuery::sendQuery(const isc::dns::QuestionPtr& question,
asio::io_service& io = dns_service_.get_io_service();
MessagePtr answer_message(new Message(Message::RENDER));
answer_message->setOpcode(isc::dns::Opcode::QUERY());
OutputBufferPtr buffer(new OutputBuffer(0));
/*
answer_message->setOpcode(isc::dns::Opcode::QUERY());
isc::resolve::ResolverCallbackDirect* rcd =
new isc::resolve::ResolverCallbackDirect(callback,
answer_message);
*/
// It will delete itself when it is done
new RunningQuery(io, *question, answer_message, upstream_,
upstream_root_, buffer, rcd, timeout_, retries_);
upstream_root_, buffer, callback, timeout_, retries_);
}
void
......@@ -589,8 +591,8 @@ RecursiveQuery::sendQuery(const Question& question,
// we're only going to handle UDP.
asio::io_service& io = dns_service_.get_io_service();
isc::resolve::ResolverCallbackServer* crs =
new isc::resolve::ResolverCallbackServer(server);
isc::resolve::ResolverInterface::CallbackPtr crs(
new isc::resolve::ResolverCallbackServer(server));
// It will delete itself when it is done
new RunningQuery(io, question, answer_message, upstream_,
......
......@@ -24,42 +24,13 @@ ResolverCallbackServer::success(isc::dns::MessagePtr response)
(void)response;
server_->resume(true);
// delete our clone now
delete server_;
delete this;
}
void
ResolverCallbackServer::failure()
{
server_->resume(false);
// delete our clone now
delete server_;
delete this;
}
void
ResolverCallbackDirect::success(isc::dns::MessagePtr response)
{
if (response &&
response->getRcode() == isc::dns::Rcode::NOERROR() &&
response->getRRCount(isc::dns::Message::SECTION_ANSWER) > 0) {
callback_->success(response);
// once called back we don't need ourselves anymore
delete this;
} else {
failure();
}
}
void
ResolverCallbackDirect::failure()
{
callback_->failure();
// once called back we don't need ourselves anymore
delete this;
}
} // namespace resolve
} // namespace isc
......@@ -21,24 +21,12 @@
namespace isc {
namespace resolve {
// We define two types of callbackholders for processing recursive
// queries; one calls back the original DNSServer to resume()
// the other uses direct callbacks (for instance when we need to
// resolve something ourselves)
// Caller warning: only callback once! The objects will delete
// themselves on callback (after they have done they callback)
class AbstractResolverCallback {
public:
~AbstractResolverCallback() {};
//virtual void callback(bool result) = 0;
virtual void success(isc::dns::MessagePtr response) = 0;
virtual void failure() = 0;
};
class ResolverCallbackServer : public AbstractResolverCallback {
class ResolverCallbackServer : public ResolverInterface::Callback {
public:
ResolverCallbackServer(asiolink::DNSServer* server) :
server_(server->clone()) {}
~ResolverCallbackServer() { delete server_; };
//void callback(bool result);
void success(isc::dns::MessagePtr response);
void failure();
......@@ -47,22 +35,6 @@ private:
asiolink::DNSServer* server_;
};
class ResolverCallbackDirect : public AbstractResolverCallback {
public:
ResolverCallbackDirect(
const isc::resolve::ResolverInterface::CallbackPtr callback,
isc::dns::MessagePtr answer_message) :
callback_(callback),
answer_message_(answer_message) {}
//void callback(bool result);
void success(isc::dns::MessagePtr response);
void failure();
private:
const isc::resolve::ResolverInterface::CallbackPtr callback_;
isc::dns::MessagePtr answer_message_;
};
} //namespace resolve
} //namespace isc
......
......@@ -16,7 +16,6 @@
#define __RESOLVER_INTERFACE_H
#include <dns/message.h>
#include <dns/rrset.h>
/**
* \file resolver_interface.h
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment