]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
added thread pool
authorRazvan Becheriu <razvan@isc.org>
Mon, 25 Mar 2019 14:34:27 +0000 (16:34 +0200)
committerRazvan Becheriu <razvan@isc.org>
Fri, 12 Apr 2019 12:19:35 +0000 (15:19 +0300)
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.cc

index eb94f087a6b4bcb11e7f75e590eb573cfb48e77b..78ea7bec3906f4229458caa8f19792e8d320efe8 100644 (file)
@@ -663,7 +663,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.
index 73a8c4c536e656010879e7e69da16cd37f9d541e..0ff829634eae426d0815538862a0d238c7f0c443 100644 (file)
@@ -750,7 +750,10 @@ Dhcpv4Srv::run() {
     while (!shutdown_) {
         try {
             run_one();
-            getIOService()->poll();
+            {
+                LockGuard<mutex> 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<mutex> lock(serverLock());
         handleSignal();
     } catch (const std::exception& e) {
         // Standard exception occurred. Let's be on the safe side to
index d3010da53c2a1db0bfddf2de742ef63377a9eb59..b4dbe22bc16c52cbd071bad19bb7bd602214c451 100644 (file)
@@ -626,8 +626,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()));
@@ -685,7 +684,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 {
index d3b4025e29a7a8e70b7f427a9182ac2d79ebcd98..407a45150e3b019519683ba349bcd81289c66f3c 100644 (file)
@@ -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<mutex> 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<mutex> lock(serverLock());
         handleSignal();
     } catch (const std::exception& e) {
         // An (a standard or ISC) exception occurred.