Commit 2d47b144 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2935] Remove the "checkin" callback for asiodns server classes

Note that this commit just removes it from libb10-asiodns. Other
dependencies have not been updated yet, as they require the checkin
callback. Please see ticket #2935.

With this commit, overall BIND 10 tree is broken.
parent 29228dab
......@@ -26,9 +26,6 @@ So, in simplified form, the behavior of a DNS Server is:
if not parent:
break
# This callback informs the caller that a packet has arrived, and
# gives it a chance to update configuration, etc
SimpleCallback(packet)
YIELD answer = DNSLookup(packet, this)
response = DNSAnswer(answer)
YIELD send(response)
......@@ -37,7 +34,7 @@ At each "YIELD" point, the coroutine initiates an asynchronous operation,
then pauses and turns over control to some other task on the ASIO service
queue. When the operation completes, the coroutine resumes.
DNSLookup, DNSAnswer and SimpleCallback define callback methods
DNSLookup and DNSAnswer define callback methods
used by a DNS Server to communicate with the module that called it.
They are abstract-only classes whose concrete implementations
are supplied by the calling module.
......
......@@ -37,9 +37,9 @@ class DNSAnswer;
class DNSServiceImpl {
public:
DNSServiceImpl(IOService& io_service, SimpleCallback* checkin,
DNSServiceImpl(IOService& io_service,
DNSLookup* lookup, DNSAnswer* answer) :
io_service_(io_service), checkin_(checkin), lookup_(lookup),
io_service_(io_service), lookup_(lookup),
answer_(answer), tcp_recv_timeout_(5000)
{}
......@@ -50,13 +50,12 @@ public:
typedef boost::shared_ptr<TCPServer> TCPServerPtr;
typedef boost::shared_ptr<DNSServer> DNSServerPtr;
std::vector<DNSServerPtr> servers_;
SimpleCallback* checkin_;
DNSLookup* lookup_;
DNSAnswer* answer_;
size_t tcp_recv_timeout_;
template<class Ptr, class Server> void addServerFromFD(int fd, int af) {
Ptr server(new Server(io_service_.get_io_service(), fd, af, checkin_,
Ptr server(new Server(io_service_.get_io_service(), fd, af,
lookup_, answer_));
startServer(server);
}
......@@ -88,9 +87,9 @@ private:
}
};
DNSService::DNSService(IOService& io_service, SimpleCallback* checkin,
DNSService::DNSService(IOService& io_service,
DNSLookup* lookup, DNSAnswer *answer) :
impl_(new DNSServiceImpl(io_service, checkin, lookup, answer)),
impl_(new DNSServiceImpl(io_service, lookup, answer)),
io_service_(io_service)
{
}
......
......@@ -107,8 +107,8 @@ public:
/// DNSService is the service that handles DNS queries and answers with
/// a given IOService. This class is mainly intended to hold all the
/// logic that is shared between the authoritative and the recursive
/// server implementations. As such, it handles asio, including config
/// updates (through the 'Checkinprovider'), and listening sockets.
/// server implementations. As such, it handles asio and listening
/// sockets.
class DNSService : public DNSServiceBase {
///
/// \name Constructors and Destructor
......@@ -132,11 +132,9 @@ public:
/// Use addServerTCPFromFD() or addServerUDPFromFD() to add some servers.
///
/// \param io_service The IOService to work with
/// \param checkin Provider for cc-channel events (see \c SimpleCallback)
/// \param lookup The lookup provider (see \c DNSLookup)
/// \param answer The answer provider (see \c DNSAnswer)
DNSService(asiolink::IOService& io_service,
isc::asiolink::SimpleCallback* checkin,
DNSLookup* lookup, DNSAnswer* answer);
/// \brief The destructor.
......
......@@ -49,11 +49,10 @@ namespace asiodns {
///
/// The constructor
TCPServer::TCPServer(io_service& io_service, int fd, int af,
const SimpleCallback* checkin,
const DNSLookup* lookup,
const DNSAnswer* answer) :
io_(io_service), done_(false),
checkin_callback_(checkin), lookup_callback_(lookup),
lookup_callback_(lookup),
answer_callback_(answer)
{
if (af != AF_INET && af != AF_INET6) {
......@@ -205,16 +204,6 @@ TCPServer::operator()(asio::error_code ec, size_t length) {
io_message_.reset(new IOMessage(data_.get(), length, *iosock_,
*peer_));
// Perform any necessary operations prior to processing the incoming
// packet (e.g., checking for queued configuration messages).
//
// (XXX: it may be a performance issue to have this called for
// every single incoming packet; we may wish to throttle it somehow
// in the future.)
if (checkin_callback_ != NULL) {
(*checkin_callback_)(*io_message_);
}
// If we don't have a DNS Lookup provider, there's no point in
// continuing; we exit the coroutine permanently.
if (lookup_callback_ == NULL) {
......
......@@ -41,14 +41,12 @@ public:
/// \param io_service the asio::io_service to work with
/// \param fd the file descriptor of opened TCP socket
/// \param af address family of the socket, either AF_INET or AF_INET6
/// \param checkin the callbackprovider for non-DNS events
/// \param lookup the callbackprovider for DNS lookup events
/// \param answer the callbackprovider for DNS answer events
/// \throw isc::InvalidParameter if af is neither AF_INET nor AF_INET6
/// \throw isc::asiolink::IOError when a low-level error happens, like the
/// fd is not a valid descriptor or it can't be listened on.
TCPServer(asio::io_service& io_service, int fd, int af,
const isc::asiolink::SimpleCallback* checkin = NULL,
const DNSLookup* lookup = NULL, const DNSAnswer* answer = NULL);
void operator()(asio::error_code ec = asio::error_code(),
......@@ -125,7 +123,6 @@ private:
bool done_;
// Callback functions provided by the caller
const isc::asiolink::SimpleCallback* checkin_callback_;
const DNSLookup* lookup_callback_;
const DNSAnswer* answer_callback_;
......
......@@ -103,14 +103,6 @@ class ServerStopper {
DNSServer* server_to_stop_;
};
// \brief no check logic at all,just provide a checkpoint to stop the server
class DummyChecker : public SimpleCallback, public ServerStopper {
public:
virtual void operator()(const IOMessage&) const {
stopServer();
}
};
// \brief no lookup logic at all,just provide a checkpoint to stop the server
class DummyLookup : public DNSLookup, public ServerStopper {
public:
......@@ -369,7 +361,6 @@ class DNSServerTestBase : public::testing::Test {
protected:
DNSServerTestBase() :
server_address_(ip::address::from_string(server_ip)),
checker_(new DummyChecker()),
lookup_(new DummyLookup()),
sync_lookup_(new SyncDummyLookup()),
answer_(new SimpleAnswer()),
......@@ -390,7 +381,6 @@ class DNSServerTestBase : public::testing::Test {
if (tcp_server_) {
tcp_server_->stop();
}
delete checker_;
delete lookup_;
delete sync_lookup_;
delete answer_;
......@@ -436,7 +426,6 @@ class DNSServerTestBase : public::testing::Test {
asio::io_service service;
const ip::address server_address_;
DummyChecker* const checker_;
DummyLookup* lookup_; // we need to replace it in some cases
SyncDummyLookup* const sync_lookup_;
SimpleAnswer* const answer_;
......@@ -507,7 +496,7 @@ protected:
this->tcp_server_ =
boost::shared_ptr<TCPServer>(new TCPServer(
this->service, fd_tcp, AF_INET6,
this->checker_, this->lookup_,
this->lookup_,
this->answer_));
}
......@@ -516,7 +505,7 @@ protected:
boost::shared_ptr<UDPServerClass> createServer(int fd, int af) {
return (boost::shared_ptr<UDPServerClass>(
new UDPServerClass(this->service, fd, af,
this->checker_, this->lookup_,
this->lookup_,
this->answer_)));
}
};
......@@ -571,16 +560,6 @@ TYPED_TEST(DNSServerTest, stopUDPServerBeforeItStartServing) {
EXPECT_TRUE(this->serverStopSucceed());
}
// Test whether udp server stopped successfully during message check.
// This only works for non-sync server; SyncUDPServer doesn't use checkin
// callback.
TEST_F(AsyncServerTest, stopUDPServerDuringMessageCheck) {
this->testStopServerByStopper(*this->udp_server_, this->udp_client_,
this->checker_);
EXPECT_EQ(std::string(""), this->udp_client_->getReceivedData());
EXPECT_TRUE(this->serverStopSucceed());
}
// Test whether udp server stopped successfully during query lookup
TYPED_TEST(DNSServerTest, stopUDPServerDuringQueryLookup) {
this->testStopServerByStopper(*this->udp_server_, this->udp_client_,
......@@ -665,14 +644,6 @@ TYPED_TEST(DNSServerTest, stopTCPServerBeforeItStartServing) {
}
// Test whether tcp server stopped successfully during message check
TYPED_TEST(DNSServerTest, stopTCPServerDuringMessageCheck) {
this->testStopServerByStopper(*this->tcp_server_, this->tcp_client_,
this->checker_);
EXPECT_EQ(std::string(""), this->tcp_client_->getReceivedData());
EXPECT_TRUE(this->serverStopSucceed());
}
// Test whether tcp server stopped successfully during query lookup
TYPED_TEST(DNSServerTest, stopTCPServerDuringQueryLookup) {
this->testStopServerByStopper(*this->tcp_server_, this->tcp_client_,
......@@ -709,7 +680,7 @@ TYPED_TEST(DNSServerTest, stopTCPServeMoreThanOnce) {
TYPED_TEST(DNSServerTestBase, invalidFamily) {
// We abuse DNSServerTestBase for this test, as we don't need the
// initialization.
EXPECT_THROW(TCPServer(this->service, 0, AF_UNIX, this->checker_,
EXPECT_THROW(TCPServer(this->service, 0, AF_UNIX,
this->lookup_, this->answer_),
isc::InvalidParameter);
}
......@@ -728,10 +699,10 @@ TYPED_TEST(DNSServerTestBase, invalidTCPFD) {
asio backend does fail as it tries to insert it right away, but
not the others, maybe we could make it run this at last on epoll-based
systems).
EXPECT_THROW(UDPServer(service, -1, AF_INET, checker_, lookup_,
EXPECT_THROW(UDPServer(service, -1, AF_INET, lookup_,
answer_), isc::asiolink::IOError);
*/
EXPECT_THROW(TCPServer(this->service, -1, AF_INET, this->checker_,
EXPECT_THROW(TCPServer(this->service, -1, AF_INET,
this->lookup_, this->answer_),
isc::asiolink::IOError);
}
......
......@@ -81,7 +81,7 @@ protected:
UDPDNSServiceTest() :
first_buffer_(NULL), second_buffer_(NULL),
lookup(&first_buffer_, &second_buffer_, io_service),
dns_service(io_service, NULL, &lookup, NULL),
dns_service(io_service, &lookup, NULL),
client_socket(io_service.get_io_service(), asio::ip::udp::v6()),
server_ep(asio::ip::address::from_string(TEST_IPV6_ADDR),
lexical_cast<uint16_t>(TEST_SERVER_PORT)),
......
......@@ -60,9 +60,9 @@ struct UDPServer::Data {
* first packet. But we do initialize the socket in here.
*/
Data(io_service& io_service, const ip::address& addr, const uint16_t port,
SimpleCallback* checkin, DNSLookup* lookup, DNSAnswer* answer) :
DNSLookup* lookup, DNSAnswer* answer) :
io_(io_service), bytes_(0), done_(false),
checkin_callback_(checkin),lookup_callback_(lookup),
lookup_callback_(lookup),
answer_callback_(answer)
{
// We must use different instantiations for v4 and v6;
......@@ -75,10 +75,10 @@ struct UDPServer::Data {
}
socket_->bind(udp::endpoint(addr, port));
}
Data(io_service& io_service, int fd, int af, SimpleCallback* checkin,
Data(io_service& io_service, int fd, int af,
DNSLookup* lookup, DNSAnswer* answer) :
io_(io_service), bytes_(0), done_(false),
checkin_callback_(checkin),lookup_callback_(lookup),
lookup_callback_(lookup),
answer_callback_(answer)
{
if (af != AF_INET && af != AF_INET6) {
......@@ -105,7 +105,6 @@ struct UDPServer::Data {
*/
Data(const Data& other) :
io_(other.io_), socket_(other.socket_), bytes_(0), done_(false),
checkin_callback_(other.checkin_callback_),
lookup_callback_(other.lookup_callback_),
answer_callback_(other.answer_callback_)
{
......@@ -169,7 +168,6 @@ struct UDPServer::Data {
bool done_;
// Callback functions provided by the caller
const SimpleCallback* checkin_callback_;
const DNSLookup* lookup_callback_;
const DNSAnswer* answer_callback_;
......@@ -182,9 +180,9 @@ struct UDPServer::Data {
/// The constructor. It just creates new internal state object
/// and lets it handle the initialization.
UDPServer::UDPServer(io_service& io_service, int fd, int af,
SimpleCallback* checkin, DNSLookup* lookup,
DNSLookup* lookup,
DNSAnswer* answer) :
data_(new Data(io_service, fd, af, checkin, lookup, answer))
data_(new Data(io_service, fd, af, lookup, answer))
{ }
/// The function operator is implemented with the "stackless coroutine"
......@@ -263,15 +261,6 @@ UDPServer::operator()(asio::error_code ec, size_t length) {
data_->io_message_.reset(new IOMessage(data_->data_.get(),
data_->bytes_, *data_->iosock_, *data_->peer_));
// Perform any necessary operations prior to processing an incoming
// query (e.g., checking for queued configuration messages).
//
// (XXX: it may be a performance issue to check in for every single
// incoming query; we may wish to throttle this in the future.)
if (data_->checkin_callback_ != NULL) {
(*data_->checkin_callback_)(*data_->io_message_);
}
// If we don't have a DNS Lookup provider, there's no point in
// continuing; we exit the coroutine permanently.
if (data_->lookup_callback_ == NULL) {
......
......@@ -43,14 +43,12 @@ public:
/// \param io_service the asio::io_service to work with
/// \param fd the file descriptor of opened UDP socket
/// \param af address family, either AF_INET or AF_INET6
/// \param checkin the callbackprovider for non-DNS events
/// \param lookup the callbackprovider for DNS lookup events
/// \param answer the callbackprovider for DNS answer events
/// \throw isc::InvalidParameter if af is neither AF_INET nor AF_INET6
/// \throw isc::asiolink::IOError when a low-level error happens, like the
/// fd is not a valid descriptor.
UDPServer(asio::io_service& io_service, int fd, int af,
isc::asiolink::SimpleCallback* checkin = NULL,
DNSLookup* lookup = NULL, DNSAnswer* answer = NULL);
/// \brief The function operator
......
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