Commit 931571d5 authored by Francis Dupont's avatar Francis Dupont

[5574] Update dhcpX/ctrl_dhcpX_src.cc

parent 4870bf0a
......@@ -603,9 +603,11 @@ ControlledDhcpv4Srv::processConfig(isc::data::ConstElementPtr config) {
// Re-open lease and host database with new parameters.
try {
DatabaseConnection::db_lost_callback =
boost::bind(&ControlledDhcpv4Srv::dbLostCallback, srv, _1);
CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
cfg_db->setAppendedParameters("universe=4");
cfg_db->createManagers(boost::bind(&ControlledDhcpv4Srv::dbLostCallback, srv, _1));
cfg_db->createManagers();
} catch (const std::exception& ex) {
err << "Unable to open database: " << ex.what();
return (isc::config::createAnswer(1, err.str()));
......@@ -777,6 +779,10 @@ ControlledDhcpv4Srv::~ControlledDhcpv4Srv() {
try {
cleanup();
// The closure captures either a shared pointer (memory leak)
// or a raw pointer (pointing to a deleted object).
DatabaseConnection::db_lost_callback = 0;
timer_mgr_->unregisterTimers();
// Close the command socket (if it exists).
......@@ -846,7 +852,7 @@ ControlledDhcpv4Srv::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
// Re-open lease and host database with new parameters.
try {
CfgDbAccessPtr cfg_db = CfgMgr::instance().getCurrentCfg()->getCfgDbAccess();
cfg_db->createManagers(boost::bind(&ControlledDhcpv4Srv::dbLostCallback, this, _1));
cfg_db->createManagers();
reopened = true;
} catch (const std::exception& ex) {
LOG_ERROR(dhcp4_logger, DHCP4_DB_RECONNECT_ATTEMPT_FAILED).arg(ex.what());
......
......@@ -587,9 +587,11 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) {
// Re-open lease and host database with new parameters.
try {
DatabaseConnection::db_lost_callback =
boost::bind(&ControlledDhcpv6Srv::dbLostCallback, srv, _1);
CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
cfg_db->setAppendedParameters("universe=6");
cfg_db->createManagers(boost::bind(&ControlledDhcpv6Srv::dbLostCallback, srv, _1));
cfg_db->createManagers();
} catch (const std::exception& ex) {
return (isc::config::createAnswer(1, "Unable to open database: "
+ std::string(ex.what())));
......@@ -762,6 +764,10 @@ ControlledDhcpv6Srv::~ControlledDhcpv6Srv() {
try {
cleanup();
// The closure captures either a shared pointer (memory leak)
// or a raw pointer (pointing to a deleted object).
DatabaseConnection::db_lost_callback = 0;
timer_mgr_->unregisterTimers();
// Close the command socket (if it exists).
......@@ -831,7 +837,7 @@ ControlledDhcpv6Srv::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
// Re-open lease and host database with new parameters.
try {
CfgDbAccessPtr cfg_db = CfgMgr::instance().getCurrentCfg()->getCfgDbAccess();
cfg_db->createManagers(boost::bind(&ControlledDhcpv6Srv::dbLostCallback, this, _1));
cfg_db->createManagers();
reopened = true;
} catch (const std::exception& ex) {
LOG_ERROR(dhcp6_logger, DHCP6_DB_RECONNECT_ATTEMPT_FAILED).arg(ex.what());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment