]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2861] interface: Add IOService parameter to the manager
authorMichal 'vorner' Vaner <vorner@vorner.cz>
Wed, 3 Jul 2013 08:30:51 +0000 (10:30 +0200)
committerMichal 'vorner' Vaner <vorner@vorner.cz>
Wed, 3 Jul 2013 08:30:51 +0000 (10:30 +0200)
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.

src/bin/auth/auth_srv.cc
src/bin/auth/datasrc_clients_mgr.h
src/bin/auth/tests/datasrc_clients_mgr_unittest.cc
src/bin/auth/tests/test_datasrc_clients_mgr.cc
src/bin/auth/tests/test_datasrc_clients_mgr.h

index ee0306fbd4cb14d16aec469b281f6b3fb30a98ee..27779a9c6ee88de95baa2ccd016a74119fedfcf0 100644 (file)
@@ -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),
index 54ebdb045a8d3db28d34f5228ae0c11f2d5c8286..3b79bed61c05d0dd09a0444e44108434e3e8f7a9 100644 (file)
@@ -29,6 +29,8 @@
 #include <datasrc/client_list.h>
 #include <datasrc/memory/zone_writer.h>
 
+#include <asiolink/io_service.h>
+
 #include <auth/auth_log.h>
 #include <auth/datasrc_config.h>
 
@@ -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 */),
index 00a47a1dbadad176594871c257f3afa713aa59d1..c805cbbd2a48c73ddd44cd996117f33678683d3c 100644 (file)
@@ -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
index fc173ef24aa5fbccb29c8b68c9e458e86acec430..e8363604a6da9533317a1a021a2dcc61088ee95e 100644 (file)
@@ -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.
index 0c2b61fcf5e760c9ccb383656bb6569521b78cdf..faf5112180e829c4700147ce58402a9ceb6432e2 100644 (file)
@@ -20,6 +20,8 @@
 #include <auth/datasrc_clients_mgr.h>
 #include <datasrc/datasrc_config.h>
 
+#include <asiolink/io_service.h>
+
 #include <boost/function.hpp>
 
 #include <list>
@@ -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<asiolink::IOService*>(this))
+    {}
+};
 } // namespace auth
 } // namespace isc