]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[master] Merge branch 'trac2211'
authorJINMEI Tatuya <jinmei@isc.org>
Tue, 23 Oct 2012 18:21:35 +0000 (11:21 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Tue, 23 Oct 2012 18:21:35 +0000 (11:21 -0700)
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

1  2 
src/bin/auth/auth_messages.mes
src/bin/auth/datasrc_clients_mgr.h
src/bin/auth/datasrc_config.h
src/bin/auth/tests/auth_srv_unittest.cc
src/bin/auth/tests/command_unittest.cc
src/bin/auth/tests/datasrc_clients_builder_unittest.cc
src/bin/auth/tests/test_datasrc_clients_mgr.cc
src/bin/auth/tests/test_datasrc_clients_mgr.h

Simple merge
index 28ddab538cdc29df9132cd51a3dfe7b64bbda5fc,c23f38421bcdc2b4b4550e56eff5f0e3991fa16a..d42d26cd0170bf9d18bf373444a1e7487fc8817f
  #include <log/logger_support.h>
  #include <log/log_dbglevels.h>
  
--#include <auth/datasrc_config.h>
++#include <dns/rrclass.h>
++
  #include <cc/data.h>
++
++#include <datasrc/data_source.h>
  #include <datasrc/client_list.h>
--#include <dns/rrclass.h>
  
  #include <auth/auth_log.h>
+ #include <auth/datasrc_config.h>
  
  #include <boost/array.hpp>
  #include <boost/bind.hpp>
@@@ -144,6 -200,35 +204,35 @@@ public
          cleanup();              // see below
      }
  
 -    void setDataSrcClientLists(datasrc::DataSrcClientListsPtr new_lists) {
+     /// \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::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 @@@ DataSrcClientsBuilderBase<MutexType, Co
                  while (command_queue_->empty()) {
                      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());
Simple merge
index 732cdcc18199ab8377e42d5eaafa565a16978e52,5d224c3e9cd8bd7ef4b63c1d393f6e4cf1bd3707..d498d9dde7983a6824a3afc357b9361f50de0a1a
@@@ -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<isc::datasrc::ConfigurableClientList> list;
+     DataSrcClientsMgr& mgr = server.getDataSrcClientsMgr();
      {
-         isc::util::thread::Mutex::Locker locker(
-             server.getDataSrcClientListMutex());
-         boost::shared_ptr<isc::datasrc::ConfigurableClientList>
-             list(new FakeList(server.getDataSrcClientList(RRClass::IN()),
-                               THROW_NEVER, false));
-         ClientListMapPtr lists(new std::map<RRClass, ListPtr>);
-         lists->insert(pair<RRClass, ListPtr>(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<RRClass, ListPtr>);
++    ClientListMapPtr lists(new std::map<RRClass, ListPtr>);
+     lists->insert(pair<RRClass, ListPtr>(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<isc::datasrc::ConfigurableClientList>
-         list(new FakeList(server.getDataSrcClientList(RRClass::IN()),
-                           throw_when, isc_exception, rrset));
+     boost::shared_ptr<isc::datasrc::ConfigurableClientList> 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<RRClass, ListPtr>);
 +    ClientListMapPtr lists(new std::map<RRClass, ListPtr>);
      lists->insert(pair<RRClass, ListPtr>(RRClass::IN(), list));
-     server.swapDataSrcClientLists(lists);
+     mgr.setDataSrcClientLists(lists);
  }
  
  TEST_F(AuthSrvTest,
index 15bd66212d44fdae933b390fed23faca18adcfa1,795d9a21d0e6973ae611da9f32b91eae7d1c1979..280def662c057b0787ea50bbd0afba2d28560aac
@@@ -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