From: JINMEI Tatuya Date: Thu, 4 Oct 2012 00:28:41 +0000 (-0700) Subject: [2203] a piggy back fix: prevent redundant initial data configuration. X-Git-Tag: trac2402_base^2~16^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c91bffdd00deb8b7f3ceda9954a84e31c0cfb9f1;p=thirdparty%2Fkea.git [2203] a piggy back fix: prevent redundant initial data configuration. this addresses the issue described in #2291. Still not really clean, but thanks to boost::bind we can centralize all the code logic in the callback, so I think it's now less likely that we forget cleaning it up when the hack is not necessary. --- diff --git a/src/bin/auth/main.cc b/src/bin/auth/main.cc index eecc5aa1a6..d0ff8f48d5 100644 --- a/src/bin/auth/main.cc +++ b/src/bin/auth/main.cc @@ -87,13 +87,25 @@ my_command_handler(const string& command, ConstElementPtr args) { } void -datasrcConfigHandler(AuthSrv* server, const std::string&, +datasrcConfigHandler(AuthSrv* server, bool* first_time, + ModuleCCSession* config_session, const std::string&, isc::data::ConstElementPtr config, const isc::config::ConfigData&) { assert(server != NULL); if (config->contains("classes")) { - configureDataSource(*server, config->get("classes")); + if (*first_time) { + // HACK: The default is not passed to the handler in the first + // callback. This one will get the default (or, current value). + // Further updates will work the usual way. + assert(config_session != NULL); + *first_time = false; + configureDataSource(*auth_server, + config_session->getRemoteConfigValue( + "data_sources", "classes")); + } else { + configureDataSource(*server, config->get("classes")); + } } } @@ -205,19 +217,16 @@ main(int argc, char* argv[]) { isc::server_common::initKeyring(*config_session); auth_server->setTSIGKeyRing(&isc::server_common::keyring); - // Start the data source configuration + // Start the data source configuration. We pass first_time and + // config_session for the hack described in datasrcConfigHandler. + bool first_time = true; config_session->addRemoteConfig("data_sources", boost::bind(datasrcConfigHandler, - auth_server, + auth_server, &first_time, + config_session, _1, _2, _3), false); - // HACK: The default is not passed to the handler. This one will - // get the default (or, current value). Further updates will work - // the usual way. - configureDataSource(*auth_server, - config_session->getRemoteConfigValue("data_sources", "classes")); - // Now start asynchronous read. config_session->start(); LOG_DEBUG(auth_logger, DBG_AUTH_START, AUTH_CONFIG_CHANNEL_STARTED);