2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 05:55:28 +00:00

[#1188] addressed review

This commit is contained in:
Razvan Becheriu
2020-04-30 13:42:19 +03:00
parent 6b8a679adf
commit ee365862b6
3 changed files with 43 additions and 27 deletions

View File

@@ -229,8 +229,9 @@ ControlledDhcpv4Srv::commandShutdownHandler(const string&, ConstElementPtr args)
ConstElementPtr
ControlledDhcpv4Srv::commandLibReloadHandler(const string&, ConstElementPtr) {
// pause dhcp service when reloading libraries
// stop thread pool (if running)
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();
@@ -354,7 +355,12 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&,
return (result);
}
// stop thread pool (if running)
MultiThreadingCriticalSection cs;
// disable multi-threading (it will be applied by new configuration)
// this must be done in order to properly handle MT to ST transition
// when 'multi-threading' structure is missing from new config
MultiThreadingMgr::instance().apply(false, 0, 0);
// We are starting the configuration process so we should remove any
@@ -415,18 +421,6 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&,
CfgMgr::instance().getCurrentCfg()->applyLoggingCfg();
}
// Configure multi threading
try {
CfgMultiThreading::apply(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading());
if (MultiThreadingMgr::instance().getMode()) {
LOG_FATAL(dhcp4_logger, DHCP4_MULTI_THREADING_WARNING);
}
} catch (const std::exception& ex) {
err << "Error applying multi threading settings: "
<< ex.what();
return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
}
return (result);
}
@@ -596,6 +590,7 @@ ControlledDhcpv4Srv::commandConfigBackendPullHandler(const std::string&,
return (createAnswer(CONTROL_RESULT_EMPTY, "No config backend."));
}
// stop thread pool (if running)
MultiThreadingCriticalSection cs;
// Reschedule the periodic CB fetch.
@@ -897,6 +892,18 @@ ControlledDhcpv4Srv::processConfig(isc::data::ConstElementPtr config) {
// operation.
}
// Configure multi threading
try {
CfgMultiThreading::apply(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading());
if (MultiThreadingMgr::instance().getMode()) {
LOG_FATAL(dhcp4_logger, DHCP4_MULTI_THREADING_WARNING);
}
} catch (const std::exception& ex) {
err << "Error applying multi threading settings: "
<< ex.what();
return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
}
return (answer);
}
@@ -1178,6 +1185,7 @@ ControlledDhcpv4Srv::dbLostCallback(ReconnectCtlPtr db_reconnect_ctl) {
void
ControlledDhcpv4Srv::cbFetchUpdates(const SrvConfigPtr& srv_cfg,
boost::shared_ptr<unsigned> failure_count) {
// stop thread pool (if running)
MultiThreadingCriticalSection cs;
try {

View File

@@ -232,8 +232,9 @@ ControlledDhcpv6Srv::commandShutdownHandler(const string&, ConstElementPtr args)
ConstElementPtr
ControlledDhcpv6Srv::commandLibReloadHandler(const string&, ConstElementPtr) {
// pause dhcp service when reloading libraries
// stop thread pool (if running)
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();
@@ -357,7 +358,12 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&,
return (result);
}
// stop thread pool (if running)
MultiThreadingCriticalSection cs;
// disable multi-threading (it will be applied by new configuration)
// this must be done in order to properly handle MT to ST transition
// when 'multi-threading' structure is missing from new config
MultiThreadingMgr::instance().apply(false, 0, 0);
// We are starting the configuration process so we should remove any
@@ -418,18 +424,6 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&,
CfgMgr::instance().getCurrentCfg()->applyLoggingCfg();
}
// Configure multi threading
try {
CfgMultiThreading::apply(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading());
if (MultiThreadingMgr::instance().getMode()) {
LOG_FATAL(dhcp6_logger, DHCP6_MULTI_THREADING_WARNING);
}
} catch (const std::exception& ex) {
err << "Error applying multi threading settings: "
<< ex.what();
return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
}
return (result);
}
@@ -599,6 +593,7 @@ ControlledDhcpv6Srv::commandConfigBackendPullHandler(const std::string&,
return (createAnswer(CONTROL_RESULT_EMPTY, "No config backend."));
}
// stop thread pool (if running)
MultiThreadingCriticalSection cs;
// Reschedule the periodic CB fetch.
@@ -918,6 +913,18 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) {
// operation.
}
// Configure multi threading
try {
CfgMultiThreading::apply(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading());
if (MultiThreadingMgr::instance().getMode()) {
LOG_FATAL(dhcp6_logger, DHCP6_MULTI_THREADING_WARNING);
}
} catch (const std::exception& ex) {
err << "Error applying multi threading settings: "
<< ex.what();
return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
}
return (answer);
}
@@ -1196,6 +1203,7 @@ ControlledDhcpv6Srv::dbLostCallback(ReconnectCtlPtr db_reconnect_ctl) {
void
ControlledDhcpv6Srv::cbFetchUpdates(const SrvConfigPtr& srv_cfg,
boost::shared_ptr<unsigned> failure_count) {
// stop thread pool (if running)
MultiThreadingCriticalSection cs;
try {

View File

@@ -20,7 +20,7 @@ public:
/// @brief parses JSON structure.
///
/// This function stores the 'multi-threading' settings in the server
/// configuration and applies the MT mode so that is can be checked when
/// configuration and updates the MT mode so that is can be checked when
/// parsing 'hooks-libraries'.
///
/// @param srv_cfg parsed value will be stored here.