Commit b1544988 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2903] more simplify SyncUDPServer: don't use checkin_callback.

parent db2e9d7c
......@@ -39,13 +39,12 @@ namespace isc {
namespace asiodns {
SyncUDPServer::SyncUDPServer(asio::io_service& io_service, const int fd,
const int af, asiolink::SimpleCallback* checkin,
const int af, asiolink::SimpleCallback*,
DNSLookup* lookup, DNSAnswer* answer) :
output_buffer_(new isc::util::OutputBuffer(0)),
query_(new isc::dns::Message(isc::dns::Message::PARSE)),
answer_(new isc::dns::Message(isc::dns::Message::RENDER)),
checkin_callback_(checkin), lookup_callback_(lookup),
answer_callback_(answer), stopped_(false)
lookup_callback_(lookup), answer_callback_(answer), stopped_(false)
{
if (af != AF_INET && af != AF_INET6) {
isc_throw(InvalidParameter, "Address family must be either AF_INET "
......@@ -107,12 +106,6 @@ SyncUDPServer::handleRead(const asio::error_code& ec, const size_t length) {
UDPSocket<DummyIOCallback> socket(*socket_);
UDPEndpoint endpoint(sender_);
IOMessage message(data_, length, socket, endpoint);
if (checkin_callback_ != NULL) {
(*checkin_callback_)(message);
if (stopped_) {
return;
}
}
// Make sure the buffers are fresh. Note that we don't touch query_
// because it's supposed to be cleared in lookup_callback_. We should
......
......@@ -51,7 +51,7 @@ 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 checkin the callbackprovider for non-DNS events (unused)
/// \param lookup the callbackprovider for DNS lookup events (must not be
/// NULL)
/// \param answer the callbackprovider for DNS answer events
......@@ -129,7 +129,6 @@ private:
// Place the socket puts the sender of a packet when it is received
asio::ip::udp::endpoint sender_;
// Callbacks
const asiolink::SimpleCallback* checkin_callback_;
const DNSLookup* lookup_callback_;
const DNSAnswer* answer_callback_;
// Answers from the lookup callback (not sent directly, but signalled
......
......@@ -503,6 +503,11 @@ typedef ::testing::Types<FdInit<UDPServer>, FdInit<SyncUDPServer> >
ServerTypes;
TYPED_TEST_CASE(DNSServerTest, ServerTypes);
// Some tests work only for SyncUDPServer, some others work only for
// (non Sync)UDPServer. We specialize these tests.
typedef FdInit<UDPServer> AsyncServerTest;
typedef FdInit<SyncUDPServer> SyncServerTest;
typedef ::testing::Types<UDPServer, SyncUDPServer> UDPServerTypes;
TYPED_TEST_CASE(DNSServerTestBase, UDPServerTypes);
......@@ -532,8 +537,10 @@ TYPED_TEST(DNSServerTest, stopUDPServerBeforeItStartServing) {
}
// Test whether udp server stopped successfully during message check
TYPED_TEST(DNSServerTest, stopUDPServerDuringMessageCheck) {
// 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());
......@@ -707,9 +714,6 @@ TYPED_TEST(DNSServerTestBase, DISABLED_invalidUDPFD) {
isc::asiolink::IOError);
}
// A specialized test type for SyncUDPServer.
typedef FdInit<SyncUDPServer> SyncServerTest;
// Check it rejects some of the unsupported operations
TEST_F(SyncServerTest, unsupportedOps) {
EXPECT_THROW(udp_server_->clone(), isc::Unexpected);
......
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