]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2780] Moved the allocator initialization
authorMarcin Siodelski <msiodelski@gmail.com>
Wed, 29 Mar 2023 06:44:29 +0000 (08:44 +0200)
committerMarcin Siodelski <msiodelski@gmail.com>
Wed, 29 Mar 2023 12:51:25 +0000 (14:51 +0200)
The FLQ allocation state is now populated before enabling MT. It was
suggested in the review.

src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc

index b6981bf1b313e12172b80a6af48edb8ddef87f34..ffdb4250a50165b55d96325532516b54c8523602 100644 (file)
@@ -1082,9 +1082,6 @@ ControlledDhcpv4Srv::finishConfigHookLibraries(isc::data::ConstElementPtr config
         }
     }
 
-    return (ConstElementPtr());
-    }
-
     // Initialize the allocators. If the user selected a Free Lease Queue Allocator
     // for any of the subnets, the server will now populate free leases to the queue.
     // It may take a while!
@@ -1094,6 +1091,20 @@ ControlledDhcpv4Srv::finishConfigHookLibraries(isc::data::ConstElementPtr config
     } catch (const std::exception& ex) {
         err << "Error initializing the lease allocators: "
             << ex.what();
+    }
+
+    // Apply multi threading settings.
+    // @note These settings are applied/updated only if no errors occur while
+    // applying the new configuration.
+    // @todo This should be fixed.
+    try {
+        CfgMultiThreading::apply(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading());
+    } catch (const std::exception& ex) {
+        err << "Error applying multi threading settings: "
+            << ex.what();
+        return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
+    }
+    return (ConstElementPtr());
 }
 
 isc::data::ConstElementPtr
index f5702ed23aba1ab442a2e0d026ac89add161b92b..847671db1396f703bfaf9db96e5ee32b2fdded67 100644 (file)
@@ -1101,7 +1101,6 @@ ControlledDhcpv6Srv::finishConfigHookLibraries(isc::data::ConstElementPtr config
         }
     }
 
-    return (ConstElementPtr());
     // Initialize the allocators. If the user selected a Free Lease Queue Allocator
     // for any of the subnets, the server will now populate free leases to the queue.
     // It may take a while!
@@ -1112,6 +1111,18 @@ ControlledDhcpv6Srv::finishConfigHookLibraries(isc::data::ConstElementPtr config
         err << "Error initializing the lease allocators: " << ex.what();
     }
 
+    // Apply multi threading settings.
+    // @note These settings are applied/updated only if no errors occur while
+    // applying the new configuration.
+    // @todo This should be fixed.
+    try {
+        CfgMultiThreading::apply(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading());
+    } catch (const std::exception& ex) {
+        err << "Error applying multi threading settings: "
+            << ex.what();
+        return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
+    }
+    return (ConstElementPtr());
 }
 
 isc::data::ConstElementPtr