From: JINMEI Tatuya Date: Tue, 23 Oct 2012 18:21:35 +0000 (-0700) Subject: [master] Merge branch 'trac2211' X-Git-Tag: trac2402_base~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d02295dada44afbbfe9c8b7878cecca536ba3a13;p=thirdparty%2Fkea.git [master] Merge branch 'trac2211' with fixing Conflicts to: src/bin/auth/auth_srv.cc src/bin/auth/auth_srv.h src/bin/auth/datasrc_clients_mgr.h src/bin/auth/main.cc src/bin/auth/tests/auth_srv_unittest.cc src/bin/auth/tests/command_unittest.cc --- d02295dada44afbbfe9c8b7878cecca536ba3a13 diff --cc src/bin/auth/datasrc_clients_mgr.h index 28ddab538c,c23f38421b..d42d26cd01 --- a/src/bin/auth/datasrc_clients_mgr.h +++ b/src/bin/auth/datasrc_clients_mgr.h @@@ -21,12 -21,13 +21,15 @@@ #include #include --#include ++#include ++ #include ++ ++#include #include --#include #include + #include #include #include @@@ -144,6 -200,35 +204,35 @@@ public cleanup(); // see below } + /// \brief Handle new full configuration for data source clients. + /// + /// This method simply passes the new configuration to the builder + /// and immediately returns. This method is basically exception free + /// as long as the caller passes a non NULL value for \c config_arg; + /// it doesn't validate the argument further. + /// + /// \brief isc::InvalidParameter config_arg is NULL. + /// \brief std::bad_alloc + /// + /// \param config_arg The new data source configuration. Must not be NULL. + void reconfigure(data::ConstElementPtr config_arg) { + if (!config_arg) { + isc_throw(InvalidParameter, "Invalid null config argument"); + } + sendCommand(datasrc_clientmgr_internal::RECONFIGURE, config_arg); + reconfigureHook(); // for test's customization + } + + /// \brief Set the underlying data source client lists to new lists. + /// + /// This is provided only for some existing tests until we support a + /// cleaner way to use faked data source clients. Non test code or + /// newer tests must not use this. - void setDataSrcClientLists(datasrc::DataSrcClientListsPtr new_lists) { ++ void setDataSrcClientLists(datasrc::ClientListMapPtr new_lists) { + typename MutexType::Locker locker(map_mutex_); + clients_map_ = new_lists; + } + private: // This is expected to be called at the end of the destructor. It // actually does nothing, but provides a customization point for @@@ -299,9 -371,8 +392,8 @@@ DataSrcClientsBuilderBaseempty()) { cond_->wait(*queue_mutex_); } - current_commands.splice(current_commands.end(), - *command_queue_); + current_commands.swap(*command_queue_); - } // the lock is release here. + } // the lock is released here. while (keep_running && !current_commands.empty()) { keep_running = handleCommand(current_commands.front()); diff --cc src/bin/auth/tests/auth_srv_unittest.cc index 732cdcc181,5d224c3e9c..d498d9dde7 --- a/src/bin/auth/tests/auth_srv_unittest.cc +++ b/src/bin/auth/tests/auth_srv_unittest.cc @@@ -726,11 -726,11 +726,11 @@@ TEST_F(AuthSrvTest, notifyWithSessionMe } void - installDataSrcClientLists(AuthSrv& server, - ClientListMapPtr lists) - { - thread::Mutex::Locker locker(server.getDataSrcClientListMutex()); - server.swapDataSrcClientLists(lists); -installDataSrcClientLists(AuthSrv& server, DataSrcClientListsPtr lists) { ++installDataSrcClientLists(AuthSrv& server, ClientListMapPtr lists) { + // For now, we use explicit swap than reconfigure() because the latter + // involves a separate thread and cannot guarantee the new config is + // available for the subsequent test. + server.getDataSrcClientsMgr().setDataSrcClientLists(lists); } void @@@ -1438,16 -1438,16 +1438,16 @@@ TEST_F(AuthSrvTest { // Set real inmem client to proxy updateInMemory(server, "example.", CONFIG_INMEMORY_EXAMPLE); + boost::shared_ptr list; + DataSrcClientsMgr& mgr = server.getDataSrcClientsMgr(); { - isc::util::thread::Mutex::Locker locker( - server.getDataSrcClientListMutex()); - boost::shared_ptr - list(new FakeList(server.getDataSrcClientList(RRClass::IN()), - THROW_NEVER, false)); - ClientListMapPtr lists(new std::map); - lists->insert(pair(RRClass::IN(), list)); - server.swapDataSrcClientLists(lists); + DataSrcClientsMgr::Holder holder(mgr); + list.reset(new FakeList(holder.findClientList(RRClass::IN()), + THROW_NEVER, false)); } - DataSrcClientListsPtr lists(new std::map); ++ ClientListMapPtr lists(new std::map); + lists->insert(pair(RRClass::IN(), list)); + server.getDataSrcClientsMgr().setDataSrcClientLists(lists); createDataFromFile("nsec3query_nodnssec_fromWire.wire"); server.processMessage(*io_message, *parse_message, *response_obuffer, @@@ -1470,14 -1470,16 +1470,16 @@@ setupThrow(AuthSrv& server, ThrowWhen t { updateInMemory(server, "example.", CONFIG_INMEMORY_EXAMPLE); - isc::util::thread::Mutex::Locker locker( - server.getDataSrcClientListMutex()); - boost::shared_ptr - list(new FakeList(server.getDataSrcClientList(RRClass::IN()), - throw_when, isc_exception, rrset)); + boost::shared_ptr list; + DataSrcClientsMgr& mgr = server.getDataSrcClientsMgr(); + { // we need to limit the scope so swap is outside of it + DataSrcClientsMgr::Holder holder(mgr); + list.reset(new FakeList(holder.findClientList(RRClass::IN()), + throw_when, isc_exception, rrset)); + } - DataSrcClientListsPtr lists(new std::map); + ClientListMapPtr lists(new std::map); lists->insert(pair(RRClass::IN(), list)); - server.swapDataSrcClientLists(lists); + mgr.setDataSrcClientLists(lists); } TEST_F(AuthSrvTest, diff --cc src/bin/auth/tests/command_unittest.cc index 15bd66212d,795d9a21d0..280def662c --- a/src/bin/auth/tests/command_unittest.cc +++ b/src/bin/auth/tests/command_unittest.cc @@@ -191,10 -192,8 +192,8 @@@ zoneChecks(AuthSrv& server) } void -installDataSrcClientLists(AuthSrv& server, DataSrcClientListsPtr lists) { +installDataSrcClientLists(AuthSrv& server, ClientListMapPtr lists) { - isc::util::thread::Mutex::Locker locker( - server.getDataSrcClientListMutex()); - server.swapDataSrcClientLists(lists); + server.getDataSrcClientsMgr().setDataSrcClientLists(lists); } void