From: Razvan Becheriu Date: Mon, 25 Mar 2019 14:34:27 +0000 (+0200) Subject: added thread pool X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7457524ff29492c15d2bf63acf3d32b797e73f60;p=thirdparty%2Fkea.git added thread pool --- diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 15c8df4cde..e40ec1a566 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -664,7 +664,7 @@ ControlledDhcpv4Srv::processConfig(isc::data::ConstElementPtr config) { // is no need to rollback configuration if socket fails to open on any // of the interfaces. CfgMgr::instance().getStagingCfg()->getCfgIface()-> - openSockets(AF_INET, srv->getServerPort(), + openSockets(AF_INET, srv->getServerPort(), srv->serverLock(), getInstance()->useBroadcast()); // Install the timers for handling leases reclamation. diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 73a8c4c536..0ff829634e 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -750,7 +750,10 @@ Dhcpv4Srv::run() { while (!shutdown_) { try { run_one(); - getIOService()->poll(); + { + LockGuard lock(serverLock()); + getIOService()->poll(); + } } catch (const std::exception& e) { // General catch-all exception that are not caught by more specific // catches. This one is for exceptions derived from std::exception. @@ -843,6 +846,7 @@ Dhcpv4Srv::run_one() { // receivePacket the process could wait up to the duration of timeout // of select() to terminate. try { + LockGuard lock(serverLock()); handleSignal(); } catch (const std::exception& e) { // Standard exception occurred. Let's be on the safe side to diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index 56905898dc..9721be4f9c 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -627,8 +627,7 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) { // Regenerate server identifier if needed. try { - const std::string duid_file = - std::string(CfgMgr::instance().getDataDir()) + "/" + + const std::string duid_file = CfgMgr::instance().getDataDir() + "/" + std::string(SERVER_DUID_FILE); DuidPtr duid = CfgMgr::instance().getStagingCfg()->getCfgDUID()->create(duid_file); server_->serverid_.reset(new Option(Option::V6, D6O_SERVERID, duid->getDuid())); @@ -686,7 +685,7 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) { // is no need to rollback configuration if socket fails to open on any // of the interfaces. CfgMgr::instance().getStagingCfg()->getCfgIface()-> - openSockets(AF_INET6, srv->getServerPort()); + openSockets(AF_INET6, srv->getServerPort(), srv->serverLock()); // Install the timers for handling leases reclamation. try { diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index d3b4025e29..407a45150e 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -242,7 +242,7 @@ Dhcpv6Srv::~Dhcpv6Srv() { // LOG_ERROR(dhcp6_logger, DHCP6_SRV_DHCP4O6_ERROR).arg(ex.what()); } - IfaceMgr::instance().closeSockets(); + IfaceMgr::instance().closeSockets(serverLock()); LeaseMgrFactory::destroy(); @@ -256,7 +256,7 @@ void Dhcpv6Srv::shutdown() { } Pkt6Ptr Dhcpv6Srv::receivePacket(int timeout) { - return (IfaceMgr::instance().receive6(timeout)); + return (IfaceMgr::instance().receive6(timeout, 0, serverLock())); } void Dhcpv6Srv::sendPacket(const Pkt6Ptr& packet) { @@ -421,7 +421,10 @@ bool Dhcpv6Srv::run() { while (!shutdown_) { try { run_one(); - getIOService()->poll(); + { + LockGuard lock(serverLock()); + getIOService()->poll(); + } } catch (const std::exception& e) { // General catch-all standard exceptions that are not caught by more // specific catches. @@ -518,6 +521,7 @@ void Dhcpv6Srv::run_one() { // process could wait up to the duration of timeout of select() to // terminate. try { + LockGuard lock(serverLock()); handleSignal(); } catch (const std::exception& e) { // An (a standard or ISC) exception occurred.