mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-03 07:25:18 +00:00
[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.
This commit is contained in:
@@ -87,15 +87,27 @@ my_command_handler(const string& command, ConstElementPtr args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
datasrcConfigHandler(AuthSrv* server, const std::string&,
|
datasrcConfigHandler(AuthSrv* server, bool* first_time,
|
||||||
|
ModuleCCSession* config_session, const std::string&,
|
||||||
isc::data::ConstElementPtr config,
|
isc::data::ConstElementPtr config,
|
||||||
const isc::config::ConfigData&)
|
const isc::config::ConfigData&)
|
||||||
{
|
{
|
||||||
assert(server != NULL);
|
assert(server != NULL);
|
||||||
if (config->contains("classes")) {
|
if (config->contains("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"));
|
configureDataSource(*server, config->get("classes"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
usage() {
|
usage() {
|
||||||
@@ -205,19 +217,16 @@ main(int argc, char* argv[]) {
|
|||||||
isc::server_common::initKeyring(*config_session);
|
isc::server_common::initKeyring(*config_session);
|
||||||
auth_server->setTSIGKeyRing(&isc::server_common::keyring);
|
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",
|
config_session->addRemoteConfig("data_sources",
|
||||||
boost::bind(datasrcConfigHandler,
|
boost::bind(datasrcConfigHandler,
|
||||||
auth_server,
|
auth_server, &first_time,
|
||||||
|
config_session,
|
||||||
_1, _2, _3),
|
_1, _2, _3),
|
||||||
false);
|
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.
|
// Now start asynchronous read.
|
||||||
config_session->start();
|
config_session->start();
|
||||||
LOG_DEBUG(auth_logger, DBG_AUTH_START, AUTH_CONFIG_CHANNEL_STARTED);
|
LOG_DEBUG(auth_logger, DBG_AUTH_START, AUTH_CONFIG_CHANNEL_STARTED);
|
||||||
|
Reference in New Issue
Block a user