diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 96fe448410..8b4872fa5d 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -229,6 +229,8 @@ ControlledDhcpv4Srv::commandShutdownHandler(const string&, ConstElementPtr args) ConstElementPtr ControlledDhcpv4Srv::commandLibReloadHandler(const string&, ConstElementPtr) { + // pause dhcp service when reloading libraries + MultiThreadingCriticalSection cs; /// @todo delete any stored CalloutHandles referring to the old libraries /// Get list of currently loaded libraries and reload them. HookLibsCollection loaded = HooksManager::getLibraryInfo(); @@ -352,6 +354,9 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&, return (result); } + // disable multi-threading (it will be applied by new configuration) + MultiThreadingMgr::instance().apply(false, 0, 0); + // We are starting the configuration process so we should remove any // staging configuration that has been created during previous // configuration attempts. @@ -662,8 +667,8 @@ ControlledDhcpv4Srv::processCommand(const string& command, if (!srv) { ConstElementPtr no_srv = isc::config::createAnswer(1, - "Server object not initialized, so can't process command '" + - command + "', arguments: '" + txt + "'."); + "Server object not initialized, so can't process command '" + + command + "', arguments: '" + txt + "'."); return (no_srv); } @@ -713,9 +718,10 @@ ControlledDhcpv4Srv::processCommand(const string& command, } else if (command == "status-get") { return (srv->commandStatusGetHandler(command, args)); } - ConstElementPtr answer = isc::config::createAnswer(1, - "Unrecognized command:" + command); - return (answer); + + return (isc::config::createAnswer(1, "Unrecognized command:" + + command)); + } catch (const Exception& ex) { return (isc::config::createAnswer(1, "Error while processing command '" + command + "':" + ex.what() + diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index eca0012180..d1ffda7afb 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -227,11 +227,13 @@ ControlledDhcpv6Srv::commandShutdownHandler(const string&, ConstElementPtr args) } ControlledDhcpv6Srv::getInstance()->shutdownServer(exit_value); - return(createAnswer(CONTROL_RESULT_SUCCESS, "Shutting down.")); + return (createAnswer(CONTROL_RESULT_SUCCESS, "Shutting down.")); } ConstElementPtr ControlledDhcpv6Srv::commandLibReloadHandler(const string&, ConstElementPtr) { + // pause dhcp service when reloading libraries + MultiThreadingCriticalSection cs; /// @todo delete any stored CalloutHandles referring to the old libraries /// Get list of currently loaded libraries and reload them. HookLibsCollection loaded = HooksManager::getLibraryInfo(); @@ -355,6 +357,9 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&, return (result); } + // disable multi-threading (it will be applied by new configuration) + MultiThreadingMgr::instance().apply(false, 0, 0); + // We are starting the configuration process so we should remove any // staging configuration that has been created during previous // configuration attempts. @@ -665,8 +670,8 @@ ControlledDhcpv6Srv::processCommand(const string& command, if (!srv) { ConstElementPtr no_srv = isc::config::createAnswer(1, - "Server object not initialized, can't process command '" + - command + "', arguments: '" + txt + "'."); + "Server object not initialized, so can't process command '" + + command + "', arguments: '" + txt + "'."); return (no_srv); } @@ -722,7 +727,8 @@ ControlledDhcpv6Srv::processCommand(const string& command, } catch (const Exception& ex) { return (isc::config::createAnswer(1, "Error while processing command '" - + command + "':" + ex.what())); + + command + "':" + ex.what() + + ", params: '" + txt + "'")); } }