-// 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
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;
-// 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
/// @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
}
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);
}
/// @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" }
};
/// @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" }
};