#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>
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
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());
}
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
{
// 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,
{
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,