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

[trac494] maka interface the same

(so we can remove one of them)
parent f0a43d24
......@@ -540,7 +540,7 @@ public:
}
if (done) {
resolvercallback_->callback(result == UDPQuery::SUCCESS);
resolvercallback_->success(answer_message_);
//server_->resume(result == UDPQuery::SUCCESS);
delete this;
}
......@@ -550,7 +550,7 @@ public:
send();
} else {
// out of retries, give up for now
resolvercallback_->callback(false);
resolvercallback_->failure();
//server_->resume(false);
delete this;
}
......
......@@ -18,32 +18,48 @@ namespace isc {
namespace resolve {
void
ResolverCallbackServer::callback(bool result) {
server_->resume(result);
ResolverCallbackServer::success(isc::dns::MessagePtr response)
{
// ignore our response here
(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::callback(bool result)
ResolverCallbackDirect::success(isc::dns::MessagePtr response)
{
// simply return with the first rrset from answer right now
if (result &&
answer_message_->getRcode() == isc::dns::Rcode::NOERROR() &&
answer_message_->getRRCount(isc::dns::Message::SECTION_ANSWER) > 0) {
/*
std::cout << *answer_message_ << std::endl;
isc::dns::RRsetIterator rrsi = answer_message_->beginSection(isc::dns::Message::SECTION_ANSWER);
const isc::dns::RRsetPtr result = *rrsi;
callback_->success(result);
*/
callback_->success(answer_message_);
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 {
callback_->failure();
failure();
}
}
void
ResolverCallbackDirect::failure()
{
callback_->failure();
// once called back we don't need ourselves anymore
delete this;
}
} // namespace resolve
} // namespace isc
......@@ -16,6 +16,7 @@
#define _ISC_RESOLVER_CALLBACK_H 1
#include <asiolink/asiolink.h>
#include <dns/message.h>
namespace isc {
namespace resolve {
......@@ -29,14 +30,18 @@ namespace resolve {
class AbstractResolverCallback {
public:
~AbstractResolverCallback() {};
virtual void callback(bool result) = 0;
//virtual void callback(bool result) = 0;
virtual void success(isc::dns::MessagePtr response) = 0;
virtual void failure() = 0;
};
class ResolverCallbackServer : public AbstractResolverCallback {
public:
ResolverCallbackServer(asiolink::DNSServer* server) :
server_(server->clone()) {}
void callback(bool result);
//void callback(bool result);
void success(isc::dns::MessagePtr response);
void failure();
private:
asiolink::DNSServer* server_;
......@@ -49,7 +54,9 @@ public:
isc::dns::MessagePtr answer_message) :
callback_(callback),
answer_message_(answer_message) {}
void callback(bool result);
//void callback(bool result);
void success(isc::dns::MessagePtr response);
void failure();
private:
const isc::resolve::ResolverInterface::CallbackPtr callback_;
......
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