2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 13:37:55 +00:00

[#893] enable command line parameters

This commit is contained in:
Razvan Becheriu
2020-03-16 17:42:45 +02:00
parent c991f87a82
commit cd334bd557
8 changed files with 48 additions and 20 deletions

View File

@@ -170,7 +170,15 @@ ControlledDhcpv4Srv::loadConfigFile(const std::string& file_name) {
}
// @todo enable multi-threading - disabled for now
MultiThreadingMgr::instance().apply(false,
bool enabled = false;
if (srv_thread_count >= 0) {
enabled = true;
}
if (enabled) {
CfgMgr::instance().getCurrentCfg()->setServerThreadCount(srv_thread_count);
CfgMgr::instance().getCurrentCfg()->setServerMaxThreadQueueSize(4);
}
MultiThreadingMgr::instance().apply(enabled,
CfgMgr::instance().getCurrentCfg()->getServerThreadCount());
// Now check is the returned result is successful (rcode=0) or not
@@ -193,10 +201,10 @@ ControlledDhcpv4Srv::loadConfigFile(const std::string& file_name) {
<< file_name << "': " << ex.what());
}
LOG_INFO(dhcp4_logger, DHCP4_MULTI_THREADING_INFO)
.arg(MultiThreadingMgr::instance().getMode())
LOG_WARN(dhcp4_logger, DHCP4_MULTI_THREADING_INFO)
.arg(MultiThreadingMgr::instance().getMode() ? "yes" : "no")
.arg(MultiThreadingMgr::instance().getPktThreadPoolSize())
.arg(CfgMgr::instance().getCurrentCfg()->getServerMaxThreadQueueSize());
.arg(CfgMgr::instance().getCurrentCfg()->getPktThreadQueueSize());
return (result);
}

View File

@@ -713,5 +713,7 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
return (answer);
}
}; // end of isc::dhcp namespace
}; // end of isc namespace
int srv_thread_count = -1;
} // namespace dhcp
} // namespace isc

View File

@@ -60,7 +60,9 @@ configureDhcp4Server(Dhcpv4Srv&,
isc::data::ConstElementPtr config_set,
bool check_only = false);
}; // end of isc::dhcp namespace
}; // end of isc namespace
extern int srv_thread_count;
} // namespace dhcp
} // namespace isc
#endif // DHCP4_CONFIG_PARSER_H

View File

@@ -59,8 +59,8 @@ usage() {
<< "(useful for testing only)" << endl;
cerr << " -P number: specify non-standard client port number 1-65535 "
<< "(useful for testing only)" << endl;
cerr << " -N number: specify thread count 0-65535 "
<< "(0 means multi-threading disabled)" << endl;
cerr << " -N number: enable multi-threading and set thread count 0-65535 "
<< "(0 means auto detect)" << endl;
exit(EXIT_FAILURE);
}
} // namespace
@@ -148,6 +148,8 @@ main(int argc, char* argv[]) {
cerr << "Failed to parse thread count number: [" << optarg
<< "], 0-65535 allowed." << endl;
usage();
} else {
srv_thread_count = thread_count;
}
break;

View File

@@ -141,7 +141,15 @@ ControlledDhcpv6Srv::loadConfigFile(const std::string& file_name) {
}
// @todo enable multi-threading - disabled for now
MultiThreadingMgr::instance().apply(false,
bool enabled = false;
if (srv_thread_count >= 0) {
enabled = true;
}
if (enabled) {
CfgMgr::instance().getCurrentCfg()->setServerThreadCount(srv_thread_count);
CfgMgr::instance().getCurrentCfg()->setServerMaxThreadQueueSize(4);
}
MultiThreadingMgr::instance().apply(enabled,
CfgMgr::instance().getCurrentCfg()->getServerThreadCount());
// Now check is the returned result is successful (rcode=0) or not
@@ -164,10 +172,10 @@ ControlledDhcpv6Srv::loadConfigFile(const std::string& file_name) {
<< file_name << "': " << ex.what());
}
LOG_INFO(dhcp6_logger, DHCP6_MULTI_THREADING_INFO)
.arg(MultiThreadingMgr::instance().getMode())
LOG_WARN(dhcp6_logger, DHCP6_MULTI_THREADING_INFO)
.arg(MultiThreadingMgr::instance().getMode() ? "yes" : "no")
.arg(MultiThreadingMgr::instance().getPktThreadPoolSize())
.arg(CfgMgr::instance().getCurrentCfg()->getServerMaxThreadQueueSize());
.arg(CfgMgr::instance().getCurrentCfg()->getPktThreadQueueSize());
return (result);
}

View File

@@ -841,5 +841,7 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
return (answer);
}
}; // end of isc::dhcp namespace
}; // end of isc namespace
int srv_thread_count = -1;
} // namespace dhcp
} // namespace isc

View File

@@ -44,7 +44,9 @@ isc::data::ConstElementPtr
configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
bool check_only = false);
}; // end of isc::dhcp namespace
}; // end of isc namespace
extern int srv_thread_count;
} // namespace dhcp
} // namespace isc
#endif // DHCP6_CONFIG_PARSER_H

View File

@@ -59,8 +59,8 @@ usage() {
<< "(useful for testing only)" << endl;
cerr << " -P number: specify non-standard client port number 1-65535 "
<< "(useful for testing only)" << endl;
cerr << " -N number: specify thread count 0-65535 "
<< "(0 means multi-threading disabled)" << endl;
cerr << " -N number: enable multi-threading and set thread count 0-65535 "
<< "(0 means auto detect)" << endl;
exit(EXIT_FAILURE);
}
} // namespace
@@ -148,6 +148,8 @@ main(int argc, char* argv[]) {
cerr << "Failed to parse thread count number: [" << optarg
<< "], 0-65535 allowed." << endl;
usage();
} else {
srv_thread_count = thread_count;
}
break;