From: Francis Dupont Date: Sat, 18 Aug 2018 22:06:52 +0000 (+0200) Subject: [3543] tentative fix X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f8d1ff278a216c9459356652ff2e1476ef0a29e;p=thirdparty%2Fkea.git [3543] tentative fix --- diff --git a/src/bin/d2/d2_cfg_mgr.cc b/src/bin/d2/d2_cfg_mgr.cc index 35a16f0b0f..2efce2ae62 100644 --- a/src/bin/d2/d2_cfg_mgr.cc +++ b/src/bin/d2/d2_cfg_mgr.cc @@ -35,8 +35,7 @@ D2CfgContext::D2CfgContext() forward_mgr_(new DdnsDomainListMgr("forward-ddns")), reverse_mgr_(new DdnsDomainListMgr("reverse-ddns")), keys_(new TSIGKeyInfoMap()), - control_socket_(ConstElementPtr()), - old_control_socket_(ConstElementPtr()) { + control_socket_(ConstElementPtr()) { } D2CfgContext::D2CfgContext(const D2CfgContext& rhs) : ConfigBase(rhs) { @@ -54,7 +53,6 @@ D2CfgContext::D2CfgContext(const D2CfgContext& rhs) : ConfigBase(rhs) { keys_ = rhs.keys_; control_socket_ = rhs.control_socket_; - old_control_socket_ = rhs.old_control_socket_; } D2CfgContext::~D2CfgContext() { @@ -247,6 +245,11 @@ D2CfgMgr::getD2Params() { return (getD2CfgContext()->getD2Params()); } +const isc::data::ConstElementPtr +D2CfgMgr::getControlSocketInfo() { + return (getD2CfgContext()->getControlSocketInfo()); +} + std::string D2CfgMgr::getConfigSummary(const uint32_t) { return (getD2Params()->getConfigSummary()); diff --git a/src/bin/d2/d2_cfg_mgr.h b/src/bin/d2/d2_cfg_mgr.h index 888653d80e..878ae3b63c 100644 --- a/src/bin/d2/d2_cfg_mgr.h +++ b/src/bin/d2/d2_cfg_mgr.h @@ -92,26 +92,15 @@ public: /// @brief Returns information about control socket /// - /// @param old When true returns the "old" value /// @return pointer to the Element that holds control-socket map - const isc::data::ConstElementPtr getControlSocketInfo(bool old = false) const { - if (!old) { - return (control_socket_); - } else { - return (old_control_socket_); - } + const isc::data::ConstElementPtr getControlSocketInfo() const { + return (control_socket_); } /// @brief Sets information about the control socket /// @param control_socket Element that holds control-socket map - /// @param old When true sets the "old" value. - void setControlSocketInfo(const isc::data::ConstElementPtr& control_socket, - bool old = false) { - if (!old) { - control_socket_ = control_socket; - } else { - old_control_socket_ = control_socket; - } + void setControlSocketInfo(const isc::data::ConstElementPtr& control_socket) { + control_socket_ = control_socket; } /// @brief Unparse a configuration object @@ -141,9 +130,6 @@ private: /// @brief Pointer to the control-socket information isc::data::ConstElementPtr control_socket_; - - /// @brief Pointer to the old control-socket information - isc::data::ConstElementPtr old_control_socket_; }; /// @brief Defines a pointer for DdnsDomain instances. @@ -284,6 +270,11 @@ public: /// @return reference to const D2ParamsPtr const D2ParamsPtr& getD2Params(); + /// @brief Returns information about control socket + /// + /// @return pointer to the Element that holds control-socket map + const isc::data::ConstElementPtr getControlSocketInfo(); + /// @brief Returns configuration summary in the textual format. /// /// @param selection Bitfield which describes the parts of the configuration diff --git a/src/bin/d2/d2_process.cc b/src/bin/d2/d2_process.cc index dbf8ee4ab3..b76bdd368a 100644 --- a/src/bin/d2/d2_process.cc +++ b/src/bin/d2/d2_process.cc @@ -199,6 +199,8 @@ D2Process::configure(isc::data::ConstElementPtr config_set, bool check_only) { .arg(check_only ? "check" : "update") .arg(config_set->str()); + isc::data::ConstElementPtr current_socket; + current_socket = getD2CfgMgr()->getControlSocketInfo(); isc::data::ConstElementPtr answer; answer = getCfgMgr()->simpleParseConfig(config_set, check_only); if (check_only) { @@ -219,7 +221,9 @@ D2Process::configure(isc::data::ConstElementPtr config_set, bool check_only) { // Set the command channel. try { - configureCommandChannel(); + isc::data::ConstElementPtr staging_socket; + staging_socket = getD2CfgMgr()->getControlSocketInfo(); + configureCommandChannel(current_socket, staging_socket); } catch (const isc::Exception& ex) { answer = isc::config::createAnswer(2, ex.what()); return (answer); @@ -245,45 +249,26 @@ D2Process::configure(isc::data::ConstElementPtr config_set, bool check_only) { } void -D2Process::configureCommandChannel() { - D2CfgMgrPtr mgr = getD2CfgMgr(); - if (!mgr) { - return; - } - D2CfgContextPtr ctx = mgr->getD2CfgContext(); - if (!ctx) { - return; - } - D2ControllerPtr ctrl = - boost::dynamic_pointer_cast(D2Controller::instance()); - if (!ctrl) { - return; - } - - // Get the previous config. - isc::data::ConstElementPtr old_sock_cfg = ctx->getControlSocketInfo(true); - - // Get the new config. - isc::data::ConstElementPtr sock_cfg = ctx->getControlSocketInfo(); - +D2Process::configureCommandChannel(isc::data::ConstElementPtr current_cfg, + isc::data::ConstElementPtr staging_cfg) { // Determine if the socket configuration has changed. It has if // both old and new configuration is specified but respective // data elements aren't equal. - bool sock_changed = (old_sock_cfg && (old_sock_cfg->size() > 0) && - sock_cfg && (sock_cfg->size() > 0) && - !sock_cfg->equals(*old_sock_cfg)); - if (old_sock_cfg && (old_sock_cfg->size() > 0) && - (!sock_cfg || (sock_cfg->size() == 0) || sock_changed)) { + bool sock_changed = (current_cfg && (current_cfg->size() > 0) && + staging_cfg && (staging_cfg->size() > 0) && + !staging_cfg->equals(*current_cfg)); + if (current_cfg && (current_cfg->size() > 0) && + (!staging_cfg || (staging_cfg->size() == 0) || sock_changed)) { // Close the existing socket. isc::config::CommandMgr::instance().closeCommandSocket(); - ctx->setControlSocketInfo(isc::data::ConstElementPtr(), true); } - if (sock_cfg && (sock_cfg->size() > 0) && - (!old_sock_cfg || (old_sock_cfg->size() == 0) || sock_changed)) { + if (staging_cfg && (staging_cfg->size() > 0) && + (!current_cfg || (current_cfg->size() == 0) || sock_changed)) { // Assume that CommandMgr works with D2 I/O. + D2ControllerPtr ctrl = + boost::dynamic_pointer_cast(D2Controller::instance()); ctrl->registerCommands(); - isc::config::CommandMgr::instance().openCommandSocket(sock_cfg, true); - ctx->setControlSocketInfo(sock_cfg, true); + isc::config::CommandMgr::instance().openCommandSocket(staging_cfg, true); } } diff --git a/src/bin/d2/d2_process.h b/src/bin/d2/d2_process.h index 83fa834cb1..bd739f5483 100644 --- a/src/bin/d2/d2_process.h +++ b/src/bin/d2/d2_process.h @@ -256,8 +256,10 @@ protected: /// @brief Configure the command channel. /// - /// Strip down code used in DHCPv4 / DHCPv6 servers. - void configureCommandChannel(); + /// @param current_cfg current configuration of the control socket. + /// @param staging_cfg staging configuration of the control socket. + void configureCommandChannel(isc::data::ConstElementPtr current_cfg, + isc::data::ConstElementPtr staging_cfg); public: /// @brief Returns a pointer to the configuration manager.