]> 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:10:40 +0000 (15:10 +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 15c8df4cdea8b872bc011cb65bef883900cc5638..e40ec1a566937843f78c5063d4ee15f25be27a0a 100644 (file)
@@ -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.
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 56905898dc7d3665a007516adc1e24c2ce7fdffc..9721be4f9c92e9f437e3015db23dd1dc614790fe 100644 (file)
@@ -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 {
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.