From: Michal 'vorner' Vaner Date: Wed, 3 Jul 2013 08:30:51 +0000 (+0200) Subject: [2861] interface: Add IOService parameter to the manager X-Git-Tag: bind10-1.2.0beta1-release~343^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=497bf6025e70ca767c703dc192a11d968c0c031d;p=thirdparty%2Fkea.git [2861] interface: Add IOService parameter to the manager It'll be needed to watch over the descriptor. Added one from the real server, and added a trick to provide one automatically in the tests. --- diff --git a/src/bin/auth/auth_srv.cc b/src/bin/auth/auth_srv.cc index ee0306fbd4..27779a9c6e 100644 --- a/src/bin/auth/auth_srv.cc +++ b/src/bin/auth/auth_srv.cc @@ -319,6 +319,7 @@ AuthSrvImpl::AuthSrvImpl(AbstractXfroutClient& xfrout_client, xfrin_session_(NULL), counters_(), keyring_(NULL), + datasrc_clients_mgr_(io_service_), ddns_base_forwarder_(ddns_forwarder), ddns_forwarder_(NULL), xfrout_connected_(false), diff --git a/src/bin/auth/datasrc_clients_mgr.h b/src/bin/auth/datasrc_clients_mgr.h index 54ebdb045a..3b79bed61c 100644 --- a/src/bin/auth/datasrc_clients_mgr.h +++ b/src/bin/auth/datasrc_clients_mgr.h @@ -29,6 +29,8 @@ #include #include +#include + #include #include @@ -193,7 +195,7 @@ public: /// /// \throw std::bad_alloc internal memory allocation failure. /// \throw isc::Unexpected general unexpected system errors. - DataSrcClientsMgrBase() : + DataSrcClientsMgrBase(asiolink::IOService&) : clients_map_(new ClientListsMap), builder_(&command_queue_, &callback_queue_, &cond_, &queue_mutex_, &clients_map_, &map_mutex_, -1 /* TEMPORARY */), diff --git a/src/bin/auth/tests/datasrc_clients_mgr_unittest.cc b/src/bin/auth/tests/datasrc_clients_mgr_unittest.cc index 00a47a1dba..c805cbbd2a 100644 --- a/src/bin/auth/tests/datasrc_clients_mgr_unittest.cc +++ b/src/bin/auth/tests/datasrc_clients_mgr_unittest.cc @@ -248,7 +248,8 @@ TEST(DataSrcClientsMgrTest, reload) { TEST(DataSrcClientsMgrTest, realThread) { // Using the non-test definition with a real thread. Just checking // no disruption happens. - DataSrcClientsMgr mgr; + isc::asiolink::IOService service; + DataSrcClientsMgr mgr(service); } } // unnamed namespace diff --git a/src/bin/auth/tests/test_datasrc_clients_mgr.cc b/src/bin/auth/tests/test_datasrc_clients_mgr.cc index fc173ef24a..e8363604a6 100644 --- a/src/bin/auth/tests/test_datasrc_clients_mgr.cc +++ b/src/bin/auth/tests/test_datasrc_clients_mgr.cc @@ -58,7 +58,7 @@ TestDataSrcClientsBuilder::doNoop() { template<> void -TestDataSrcClientsMgr::cleanup() { +TestDataSrcClientsMgrBase::cleanup() { using namespace datasrc_clientmgr_internal; // Make copy of some of the manager's member variables and reset the // corresponding pointers. The currently pointed objects are in the @@ -77,7 +77,7 @@ TestDataSrcClientsMgr::cleanup() { template<> void -TestDataSrcClientsMgr::reconfigureHook() { +TestDataSrcClientsMgrBase::reconfigureHook() { using namespace datasrc_clientmgr_internal; // Simply replace the local map, ignoring bogus config value. diff --git a/src/bin/auth/tests/test_datasrc_clients_mgr.h b/src/bin/auth/tests/test_datasrc_clients_mgr.h index 0c2b61fcf5..faf5112180 100644 --- a/src/bin/auth/tests/test_datasrc_clients_mgr.h +++ b/src/bin/auth/tests/test_datasrc_clients_mgr.h @@ -20,6 +20,8 @@ #include #include +#include + #include #include @@ -202,18 +204,30 @@ typedef DataSrcClientsMgrBase< datasrc_clientmgr_internal::TestThread, datasrc_clientmgr_internal::FakeDataSrcClientsBuilder, datasrc_clientmgr_internal::TestMutex, - datasrc_clientmgr_internal::TestCondVar> TestDataSrcClientsMgr; + datasrc_clientmgr_internal::TestCondVar> TestDataSrcClientsMgrBase; // A specialization of manager's "cleanup" called at the end of the // destructor. We use this to record the final values of some of the class // member variables. template<> void -TestDataSrcClientsMgr::cleanup(); +TestDataSrcClientsMgrBase::cleanup(); template<> void -TestDataSrcClientsMgr::reconfigureHook(); +TestDataSrcClientsMgrBase::reconfigureHook(); + +// A (hackish) trick how to not require the IOService to be passed from the +// tests. We can't create the io service as a member, because it would +// get initialized too late. +class TestDataSrcClientsMgr : + public asiolink::IOService, + public TestDataSrcClientsMgrBase { +public: + TestDataSrcClientsMgr() : + TestDataSrcClientsMgrBase(*static_cast(this)) + {} +}; } // namespace auth } // namespace isc