]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2402] enable MT by default
authorAndrei Pavel <andrei@isc.org>
Mon, 6 Feb 2023 20:22:43 +0000 (22:22 +0200)
committerAndrei Pavel <andrei@isc.org>
Tue, 14 Feb 2023 12:23:05 +0000 (14:23 +0200)
src/lib/dhcpsrv/cfg_multi_threading.cc
src/lib/dhcpsrv/cfg_multi_threading.h
src/lib/dhcpsrv/parsers/multi_threading_config_parser.cc
src/lib/dhcpsrv/parsers/simple_parser4.cc
src/lib/dhcpsrv/parsers/simple_parser6.cc

index c31e6a720f011f49c8bf48e1d629f7a8a295e6f7..59a0835a6a5731575559e12aecf0b6b14e8e2daa 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2021 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2020-2023 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -19,6 +19,7 @@ namespace dhcp {
 
 void
 CfgMultiThreading::apply(ConstElementPtr value) {
+    // Note the default values are set by extract, not here!
     bool enabled = false;
     uint32_t thread_count = 0;
     uint32_t queue_size = 0;
index f7e07fa68fafda7aba7bbf41d0a37e267943f3c5..37f78974c29cd11ab2887fb555af029d040eeb31 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2020-2023 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -21,7 +21,12 @@ public:
     /// @param value The multi-threading configuration
     static void apply(data::ConstElementPtr value);
 
-    /// @brief extract multi threading parameters
+    /// @brief Extract multi-threading parameters from a given configuration.
+    ///
+    /// If the configuration does not contain the enable parameter,
+    /// multi-threading is disabled. This is very useful as a default value for
+    /// unit tests, so that they are kept simple, and that they can enable
+    /// multi-threading on their own if it is in their scope to test MT.
     ///
     /// @param[in] value The multi-threading configuration
     /// @param[out] enabled The enabled flag
index 119461875655ef9285d3a61218e9edb8239d98c1..115f2a38fb30ae66107db5691537adca0e6e2989 100644 (file)
@@ -65,6 +65,15 @@ MultiThreadingConfigParser::parse(SrvConfig& srv_cfg,
     }
 
     srv_cfg.setDHCPMultiThreading(value);
+
+    // Set the mode so that it can be inspected by other configuration parsers
+    // such as the ones in hook libraries. This creates a dangerous discordance
+    // between the MT mode and the real configuration. For instance, it may
+    // result in packets not being processed because the listener thread sees
+    // the MT mode enabled, but in fact there are 0 threads to handle the
+    // packets. In production code, it is expected that a call to
+    // ControlledDhcpvXSrv::processConfig() applies the configuration, which
+    // should properly create the threads and close this divide.
     MultiThreadingMgr::instance().setMode(enabled);
 }
 
index e33c0e5f4a929ce0ded3459e98e7a67ef6d1ed5e..2475fc49a6e59771e7385f64cd404b2909cedbd5 100644 (file)
@@ -393,7 +393,7 @@ const SimpleDefaults SimpleParser4::DHCP_QUEUE_CONTROL4_DEFAULTS = {
 
 /// @brief This table defines default values for multi-threading in DHCPv4.
 const SimpleDefaults SimpleParser4::DHCP_MULTI_THREADING4_DEFAULTS = {
-    { "enable-multi-threading", Element::boolean, "false" },
+    { "enable-multi-threading", Element::boolean, "true" },
     { "thread-pool-size",       Element::integer, "0" },
     { "packet-queue-size",      Element::integer, "64" }
 };
index a665640fb9ec9d11fb9258c85c4602c20e032f45..eae89340c7d699f2f974665dfd79931236e2cd32 100644 (file)
@@ -410,7 +410,7 @@ const SimpleDefaults SimpleParser6::DHCP_QUEUE_CONTROL6_DEFAULTS = {
 
 /// @brief This table defines default values for multi-threading in DHCPv6.
 const SimpleDefaults SimpleParser6::DHCP_MULTI_THREADING6_DEFAULTS = {
-    { "enable-multi-threading", Element::boolean, "false" },
+    { "enable-multi-threading", Element::boolean, "true" },
     { "thread-pool-size",       Element::integer, "0" },
     { "packet-queue-size",      Element::integer, "64" }
 };