]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2799] call setMode only on config-set
authorRazvan Becheriu <razvan@isc.org>
Tue, 21 Mar 2023 11:47:29 +0000 (13:47 +0200)
committerRazvan Becheriu <razvan@isc.org>
Fri, 24 Mar 2023 10:12:40 +0000 (12:12 +0200)
31 files changed:
src/bin/agent/simple_parser.cc
src/bin/agent/tests/ca_response_creator_unittests.cc
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/json_config_parser.cc
src/bin/dhcp4/tests/hooks_unittest.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/json_config_parser.cc
src/bin/dhcp6/tests/hooks_unittest.cc
src/bin/netconf/simple_parser.cc
src/hooks/dhcp/high_availability/ha_callouts.cc
src/hooks/dhcp/run_script/run_script_callouts.cc
src/lib/d2srv/d2_simple_parser.cc
src/lib/dhcpsrv/cfg_multi_threading.cc
src/lib/dhcpsrv/parsers/dhcp_queue_control_parser.cc
src/lib/dhcpsrv/parsers/dhcp_queue_control_parser.h
src/lib/dhcpsrv/parsers/multi_threading_config_parser.cc
src/lib/dhcpsrv/tests/cfg_multi_threading_unittest.cc
src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc
src/lib/dhcpsrv/tests/dhcp_queue_control_parser_unittest.cc
src/lib/dhcpsrv/tests/multi_threading_config_parser_unittest.cc
src/lib/hooks/hooks_config.cc
src/lib/hooks/hooks_config.h
src/lib/hooks/hooks_manager.cc
src/lib/hooks/hooks_manager.h
src/lib/hooks/library_manager.cc
src/lib/hooks/library_manager.h
src/lib/hooks/library_manager_collection.cc
src/lib/hooks/library_manager_collection.h
src/lib/hooks/tests/library_manager_unittest.cc
src/lib/http/client.cc
src/lib/http/tests/client_mt_unittests.cc

index 0b267e70307e265963a0a2beabdb35f739b77d89..4c9acb04eae8c177a7f44136bba5eac391855e33 100644 (file)
@@ -174,7 +174,7 @@ AgentSimpleParser::parse(const CtrlAgentCfgContextPtr& ctx,
     if (hooks) {
         HooksLibrariesParser hooks_parser;
         hooks_parser.parse(libraries, hooks);
-        libraries.verifyLibraries(hooks->getPosition());
+        libraries.verifyLibraries(hooks->getPosition(), false);
     }
 
     if (!check_only) {
@@ -183,7 +183,7 @@ AgentSimpleParser::parse(const CtrlAgentCfgContextPtr& ctx,
         // change causes problems when trying to roll back.
         HooksManager::prepareUnloadLibraries();
         static_cast<void>(HooksManager::unloadLibraries());
-        libraries.loadLibraries();
+        libraries.loadLibraries(false);
     }
 }
 
index fe3895dd82361f362acfccde6bdc6f7531a65e50..d71a1bbccb7fbd6bc3a9b6ffd6a1e1871297dd59 100644 (file)
@@ -359,7 +359,7 @@ TEST_F(CtrlAgentResponseCreatorTest, hookNoAuth) {
     ConstElementPtr auth_json;
     ASSERT_NO_THROW(auth_json = Element::fromJSON(auth_cfg));
     hooks_cfg.add(std::string(BASIC_AUTH_LIBRARY), auth_json);
-    ASSERT_NO_THROW(hooks_cfg.loadLibraries());
+    ASSERT_NO_THROW(hooks_cfg.loadLibraries(false));
 
     HttpResponsePtr response;
     ASSERT_NO_THROW(response = response_creator_.createHttpResponse(request_));
@@ -434,7 +434,7 @@ TEST_F(CtrlAgentResponseCreatorTest, hookBasicAuth) {
     ConstElementPtr auth_json;
     ASSERT_NO_THROW(auth_json = Element::fromJSON(auth_cfg));
     hooks_cfg.add(std::string(BASIC_AUTH_LIBRARY), auth_json);
-    ASSERT_NO_THROW(hooks_cfg.loadLibraries());
+    ASSERT_NO_THROW(hooks_cfg.loadLibraries(false));
 
     HttpResponsePtr response;
     ASSERT_NO_THROW(response = response_creator_.createHttpResponse(request_));
index 66a369b118c483561383d5b4245e1a68441de5c7..c0b66ee14977d3b396a3b44f2773a14ea23bde9d 100644 (file)
@@ -239,7 +239,12 @@ ControlledDhcpv4Srv::commandLibReloadHandler(const string&, ConstElementPtr) {
         HookLibsCollection loaded = HooksManager::getLibraryInfo();
         HooksManager::prepareUnloadLibraries();
         static_cast<void>(HooksManager::unloadLibraries());
-        bool status = HooksManager::loadLibraries(loaded);
+        bool multi_threading_enabled = true;
+        uint32_t thread_count = 0;
+        uint32_t queue_size = 0;
+        CfgMultiThreading::extract(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading(),
+                                   multi_threading_enabled, thread_count, queue_size);
+        bool status = HooksManager::loadLibraries(loaded, multi_threading_enabled);
         if (!status) {
             isc_throw(Unexpected, "Failed to reload hooks libraries "
                                   "(WARNING: libreload is deprecated).");
index 09466e89b3ec0fcd53d1de249b6f8a143ff47c83..3508de36a876630c0a190e6398be2b1d6f579c5c 100644 (file)
@@ -18,6 +18,7 @@
 #include <dhcp/libdhcp++.h>
 #include <dhcp/option_definition.h>
 #include <dhcpsrv/cb_ctl_dhcp4.h>
+#include <dhcpsrv/cfg_multi_threading.h>
 #include <dhcpsrv/cfg_option.h>
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/config_backend_dhcp4_mgr.h>
@@ -411,19 +412,25 @@ processDhcp4Config(isc::data::ConstElementPtr config_set) {
             parser.parse(*srv_config, multi_threading);
         }
 
+        bool multi_threading_enabled = true;
+        uint32_t thread_count = 0;
+        uint32_t queue_size = 0;
+        CfgMultiThreading::extract(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading(),
+                                   multi_threading_enabled, thread_count, queue_size);
+
         /// depends on "multi-threading" being enabled, so it must come after.
         ConstElementPtr queue_control = mutable_cfg->get("dhcp-queue-control");
         if (queue_control) {
             parameter_name = "dhcp-queue-control";
             DHCPQueueControlParser parser;
-            srv_config->setDHCPQueueControl(parser.parse(queue_control));
+            srv_config->setDHCPQueueControl(parser.parse(queue_control, multi_threading_enabled));
         }
 
         /// depends on "multi-threading" being enabled, so it must come after.
         ConstElementPtr reservations_lookup_first = mutable_cfg->get("reservations-lookup-first");
         if (reservations_lookup_first) {
             parameter_name = "reservations-lookup-first";
-            if (MultiThreadingMgr::instance().getMode()) {
+            if (multi_threading_enabled) {
                 LOG_WARN(dhcp4_logger, DHCP4_RESERVATIONS_LOOKUP_FIRST_ENABLED);
             }
             srv_config->setReservationsLookupFirst(reservations_lookup_first->boolValue());
@@ -469,7 +476,8 @@ processDhcp4Config(isc::data::ConstElementPtr config_set) {
             HooksLibrariesParser hooks_parser;
             HooksConfig& libraries = srv_config->getHooksConfig();
             hooks_parser.parse(libraries, hooks_libraries);
-            libraries.verifyLibraries(hooks_libraries->getPosition());
+            libraries.verifyLibraries(hooks_libraries->getPosition(),
+                                      multi_threading_enabled);
         }
 
         // D2 client configuration.
@@ -903,7 +911,12 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
             static_cast<void>(HooksManager::unloadLibraries());
             const HooksConfig& libraries =
                 CfgMgr::instance().getStagingCfg()->getHooksConfig();
-            libraries.loadLibraries();
+            bool multi_threading_enabled = true;
+            uint32_t thread_count = 0;
+            uint32_t queue_size = 0;
+            CfgMultiThreading::extract(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading(),
+                                       multi_threading_enabled, thread_count, queue_size);
+            libraries.loadLibraries(multi_threading_enabled);
         } catch (const isc::Exception& ex) {
             LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(ex.what());
             answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, ex.what());
index c40b25761333367664065ceddcac63af15fad48d..af533abb76e1f113c0124c6017a165a77b4dcb32 100644 (file)
@@ -3175,8 +3175,6 @@ TEST_F(LoadUnloadDhcpv4SrvTest, failLoadIncompatibleLibraries) {
 
     ASSERT_NO_THROW(server_.reset(new NakedDhcpv4Srv()));
 
-    MultiThreadingMgr::instance().setMode(true);
-
     // Ensure no marker files to start with.
     ASSERT_FALSE(checkMarkerFileExists(LOAD_MARKER_FILE));
     ASSERT_FALSE(checkMarkerFileExists(UNLOAD_MARKER_FILE));
@@ -3186,7 +3184,7 @@ TEST_F(LoadUnloadDhcpv4SrvTest, failLoadIncompatibleLibraries) {
     libraries.push_back(make_pair(std::string(CALLOUT_LIBRARY_2),
                                   ConstElementPtr()));
 
-    ASSERT_FALSE(HooksManager::loadLibraries(libraries));
+    ASSERT_FALSE(HooksManager::loadLibraries(libraries, true));
 
     // The library is missing multi_threading_compatible function so loading
     // should fail
@@ -3197,7 +3195,7 @@ TEST_F(LoadUnloadDhcpv4SrvTest, failLoadIncompatibleLibraries) {
     libraries.push_back(make_pair(std::string(CALLOUT_LIBRARY_3),
                                   ConstElementPtr()));
 
-    ASSERT_FALSE(HooksManager::loadLibraries(libraries));
+    ASSERT_FALSE(HooksManager::loadLibraries(libraries, true));
 
     // The library is not multi threading compatible so loading should fail
     EXPECT_FALSE(checkMarkerFileExists(LOAD_MARKER_FILE));
index 55c3046dbf37566e3e24d9f88ffac3a8ece22d73..717bf6678653eaac8c1f29e365f003500ccd7060 100644 (file)
@@ -242,7 +242,12 @@ ControlledDhcpv6Srv::commandLibReloadHandler(const string&, ConstElementPtr) {
         HookLibsCollection loaded = HooksManager::getLibraryInfo();
         HooksManager::prepareUnloadLibraries();
         static_cast<void>(HooksManager::unloadLibraries());
-        bool status = HooksManager::loadLibraries(loaded);
+        bool multi_threading_enabled = true;
+        uint32_t thread_count = 0;
+        uint32_t queue_size = 0;
+        CfgMultiThreading::extract(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading(),
+                                   multi_threading_enabled, thread_count, queue_size);
+        bool status = HooksManager::loadLibraries(loaded, multi_threading_enabled);
         if (!status) {
             isc_throw(Unexpected, "Failed to reload hooks libraries"
                                   " (WARNING: libreload is deprecated).");
index f7151afda100a2bf0fa455f544c3190bb39915d5..6267ab8eac06bb03b76fa17b55895d89e32decb6 100644 (file)
@@ -18,6 +18,7 @@
 #include <dhcp/libdhcp++.h>
 #include <dhcp/iface_mgr.h>
 #include <dhcpsrv/cb_ctl_dhcp4.h>
+#include <dhcpsrv/cfg_multi_threading.h>
 #include <dhcpsrv/cfg_option.h>
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/db_type.h>
@@ -529,19 +530,25 @@ processDhcp6Config(isc::data::ConstElementPtr config_set) {
             parser.parse(*srv_config, multi_threading);
         }
 
+        bool multi_threading_enabled = true;
+        uint32_t thread_count = 0;
+        uint32_t queue_size = 0;
+        CfgMultiThreading::extract(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading(),
+                                   multi_threading_enabled, thread_count, queue_size);
+
         /// depends on "multi-threading" being enabled, so it must come after.
         ConstElementPtr queue_control = mutable_cfg->get("dhcp-queue-control");
         if (queue_control) {
             parameter_name = "dhcp-queue-control";
             DHCPQueueControlParser parser;
-            srv_config->setDHCPQueueControl(parser.parse(queue_control));
+            srv_config->setDHCPQueueControl(parser.parse(queue_control, multi_threading_enabled));
         }
 
         /// depends on "multi-threading" being enabled, so it must come after.
         ConstElementPtr reservations_lookup_first = mutable_cfg->get("reservations-lookup-first");
         if (reservations_lookup_first) {
             parameter_name = "reservations-lookup-first";
-            if (MultiThreadingMgr::instance().getMode()) {
+            if (multi_threading_enabled) {
                 LOG_WARN(dhcp6_logger, DHCP6_RESERVATIONS_LOOKUP_FIRST_ENABLED);
             }
             srv_config->setReservationsLookupFirst(reservations_lookup_first->boolValue());
@@ -595,7 +602,8 @@ processDhcp6Config(isc::data::ConstElementPtr config_set) {
             HooksLibrariesParser hooks_parser;
             HooksConfig& libraries = srv_config->getHooksConfig();
             hooks_parser.parse(libraries, hooks_libraries);
-            libraries.verifyLibraries(hooks_libraries->getPosition());
+            libraries.verifyLibraries(hooks_libraries->getPosition(),
+                                      multi_threading_enabled);
         }
 
         // D2 client configuration.
@@ -1028,7 +1036,12 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
             static_cast<void>(HooksManager::unloadLibraries());
             const HooksConfig& libraries =
                 CfgMgr::instance().getStagingCfg()->getHooksConfig();
-            libraries.loadLibraries();
+            bool multi_threading_enabled = true;
+            uint32_t thread_count = 0;
+            uint32_t queue_size = 0;
+            CfgMultiThreading::extract(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading(),
+                                       multi_threading_enabled, thread_count, queue_size);
+            libraries.loadLibraries(multi_threading_enabled);
         } catch (const isc::Exception& ex) {
             LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_FAIL).arg(ex.what());
             answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, ex.what());
index 15aec5d1ef67ca8ced77cb6efa38f6bd689c311c..3e59b7f9f31d5de2fd5eb56af87ada7d6f858c0d 100644 (file)
@@ -5554,8 +5554,6 @@ TEST_F(LoadUnloadDhcpv6SrvTest, failLoadIncompatibleLibraries) {
 
     ASSERT_NO_THROW(server_.reset(new NakedDhcpv6Srv(0)));
 
-    MultiThreadingMgr::instance().setMode(true);
-
     // Ensure no marker files to start with.
     ASSERT_FALSE(checkMarkerFileExists(LOAD_MARKER_FILE));
     ASSERT_FALSE(checkMarkerFileExists(UNLOAD_MARKER_FILE));
@@ -5565,7 +5563,7 @@ TEST_F(LoadUnloadDhcpv6SrvTest, failLoadIncompatibleLibraries) {
     libraries.push_back(make_pair(std::string(CALLOUT_LIBRARY_2),
                                   ConstElementPtr()));
 
-    ASSERT_FALSE(HooksManager::loadLibraries(libraries));
+    ASSERT_FALSE(HooksManager::loadLibraries(libraries, true));
 
     // The library is missing multi_threading_compatible function so loading
     // should fail
@@ -5576,7 +5574,7 @@ TEST_F(LoadUnloadDhcpv6SrvTest, failLoadIncompatibleLibraries) {
     libraries.push_back(make_pair(std::string(CALLOUT_LIBRARY_3),
                                   ConstElementPtr()));
 
-    ASSERT_FALSE(HooksManager::loadLibraries(libraries));
+    ASSERT_FALSE(HooksManager::loadLibraries(libraries, true));
 
     // The library is not multi threading compatible so loading should fail
     EXPECT_FALSE(checkMarkerFileExists(LOAD_MARKER_FILE));
index efb497379e124fc9a39517c1f547624744c85a8f..cc58bb67b743f499209a4086f369e950a50bb57c 100644 (file)
@@ -180,7 +180,7 @@ NetconfSimpleParser::parse(const NetconfConfigPtr& ctx,
     if (hooks) {
         HooksLibrariesParser hooks_parser;
         hooks_parser.parse(libraries, hooks);
-        libraries.verifyLibraries(hooks->getPosition());
+        libraries.verifyLibraries(hooks->getPosition(), false);
     }
 
     if (!check_only) {
@@ -189,7 +189,7 @@ NetconfSimpleParser::parse(const NetconfConfigPtr& ctx,
         // change causes problems when trying to roll back.
         HooksManager::prepareUnloadLibraries();
         static_cast<void>(HooksManager::unloadLibraries());
-        libraries.loadLibraries();
+        libraries.loadLibraries(false);
     }
 }
 
index 7c3546d34e605f57359d82fba3cfbef8a8f7246d..9988f01b9668367d9c2a7a9777f59981de5707af 100644 (file)
@@ -51,6 +51,7 @@ int dhcp4_srv_configured(CalloutHandle& handle) {
     } catch (const std::exception& ex) {
         LOG_ERROR(ha_logger, HA_DHCP4_START_SERVICE_FAILED)
             .arg(ex.what());
+        handle.setStatus(isc::hooks::CalloutHandle::NEXT_STEP_DROP);
         return (1);
     }
     return (0);
@@ -113,6 +114,7 @@ int dhcp6_srv_configured(CalloutHandle& handle) {
     } catch (const std::exception& ex) {
         LOG_ERROR(ha_logger, HA_DHCP6_START_SERVICE_FAILED)
             .arg(ex.what());
+        handle.setStatus(isc::hooks::CalloutHandle::NEXT_STEP_DROP);
         return (1);
     }
     return (0);
index f315aaadd7b334b2d461f5d5e9c1482f14febab2..4a339278f0288fc9fc2357c34ebada0c44c27ae8 100644 (file)
@@ -95,6 +95,7 @@ int dhcp4_srv_configured(CalloutHandle& handle) {
     } catch (const std::exception& ex) {
         LOG_ERROR(run_script_logger, RUN_SCRIPT_LOAD_ERROR)
             .arg(ex.what());
+        handle.setStatus(isc::hooks::CalloutHandle::NEXT_STEP_DROP);
         return (1);
     }
     return (0);
@@ -112,6 +113,7 @@ int dhcp6_srv_configured(CalloutHandle& handle) {
     } catch (const std::exception& ex) {
         LOG_ERROR(run_script_logger, RUN_SCRIPT_LOAD_ERROR)
             .arg(ex.what());
+        handle.setStatus(isc::hooks::CalloutHandle::NEXT_STEP_DROP);
         return (1);
     }
     return (0);
index c57d29edfb3ddfdf2211a457aeb99357ee8c6097..c24dfdcc9abd4e098d61a98b798ee175b4abe989 100644 (file)
@@ -286,7 +286,7 @@ void D2SimpleParser::parse(const D2CfgContextPtr& ctx,
     if (hooks) {
         HooksLibrariesParser hooks_parser;
         hooks_parser.parse(libraries, hooks);
-        libraries.verifyLibraries(hooks->getPosition());
+        libraries.verifyLibraries(hooks->getPosition(), false);
     }
 
     // Attempt to create the new client config. This ought to fly as
@@ -302,7 +302,7 @@ void D2SimpleParser::parse(const D2CfgContextPtr& ctx,
         // change causes problems when trying to roll back.
         HooksManager::prepareUnloadLibraries();
         static_cast<void>(HooksManager::unloadLibraries());
-        libraries.loadLibraries();
+        libraries.loadLibraries(false);
     }
 }
 
index 59a0835a6a5731575559e12aecf0b6b14e8e2daa..99689742caac4751e058daaeff57735b947c32a9 100644 (file)
@@ -30,7 +30,7 @@ CfgMultiThreading::apply(ConstElementPtr value) {
 void
 CfgMultiThreading::extract(ConstElementPtr value, bool& enabled,
                            uint32_t& thread_count, uint32_t& queue_size) {
-    enabled = false;
+    enabled = true;
     thread_count = 0;
     queue_size = 0;
     if (value) {
index a07e1e2fe224bad10c7663d73405a7085cc7dac2..2169ea2290dd6d50e0e0f0bfec60a074d43a42e7 100644 (file)
@@ -21,7 +21,8 @@ namespace isc {
 namespace dhcp {
 
 ElementPtr
-DHCPQueueControlParser::parse(const ConstElementPtr& control_elem) {
+DHCPQueueControlParser::parse(const ConstElementPtr& control_elem,
+                              bool multi_threading_enabled) {
     // All we really do here is verify that it is a map that
     // contains at least queue-type.  All other content depends
     // on the packet queue implementation of that type.
@@ -47,7 +48,7 @@ DHCPQueueControlParser::parse(const ConstElementPtr& control_elem) {
     ElementPtr result = data::copy(control_elem);
 
     // Currently not compatible with multi-threading.
-    if (MultiThreadingMgr::instance().getMode()) {
+    if (multi_threading_enabled) {
         // Silently disable it.
         result->set("enable-queue", Element::create(false));
     }
index 663874903f6cb2e87cb530b8c2691b559d837bc2..437dd0a0496d9ae9d0e8789f821b6fb3320cd6d9 100644 (file)
@@ -34,19 +34,20 @@ namespace dhcp {
 class DHCPQueueControlParser : public isc::data::SimpleParser {
 public:
 
-    /// @brief Constructor
-    ///
+    /// @brief Constructor.
     DHCPQueueControlParser(){};
 
     /// @brief Parses content of the "dhcp-queue-control".
     ///
     /// @param control_elem  MapElement containing the queue control values to
-    /// parse
+    /// parse.
+    /// @param multi_threading_enabled The flag which indicates if MT is enabled.
     ///
     /// @return A copy of the of the input MapElement.
     ///
     /// @throw DhcpConfigError if any of the values are invalid.
-    data::ElementPtr parse(const isc::data::ConstElementPtr& control_elem);
+    data::ElementPtr parse(const isc::data::ConstElementPtr& control_elem,
+                           bool multi_threading_enabled);
 
 private:
 };
index 245caf4e99846d2ed1f245857f1aa52504803584..8793ba67b99b196e20943bde8d94a0beb50e3828 100644 (file)
@@ -28,7 +28,7 @@ MultiThreadingConfigParser::parse(SrvConfig& srv_cfg,
     }
 
     // enable-multi-threading is mandatory
-    auto enabled = getBoolean(value, "enable-multi-threading");
+    getBoolean(value, "enable-multi-threading");
 
     // thread-pool-size is not mandatory
     if (value->get("thread-pool-size")) {
@@ -65,16 +65,6 @@ 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);
 }
 
 }  // namespace dhcp
index 3d9de82f6546e4ec4b5592a8cc874b898731f9c8..4cc6676e7bb07179b564dd233f3b6014088268db 100644 (file)
@@ -77,7 +77,7 @@ TEST_F(CfgMultiThreadingTest, extract) {
     //check empty config
     ASSERT_NO_THROW(CfgMultiThreading::extract(param, enabled, thread_count,
                     queue_size));
-    EXPECT_EQ(enabled, false);
+    EXPECT_EQ(enabled, true);
     EXPECT_EQ(thread_count, 0);
     EXPECT_EQ(queue_size, 0);
 
@@ -87,7 +87,7 @@ TEST_F(CfgMultiThreadingTest, extract) {
     // check empty data
     ASSERT_NO_THROW(CfgMultiThreading::extract(ConstElementPtr(), enabled,
                     thread_count, queue_size));
-    EXPECT_EQ(enabled, false);
+    EXPECT_EQ(enabled, true);
     EXPECT_EQ(thread_count, 0);
     EXPECT_EQ(queue_size, 0);
 }
index 3d6703d8506cd499f5098d9e623641216fc820a0..50b05b3c5d881337566bbc792e29923eac075261 100644 (file)
@@ -91,7 +91,7 @@ TEST_F(DhcpParserTest, MacSources) {
     EXPECT_NO_THROW(parser.parse(sources, values));
 
     // Finally, check the sources that were configured
-    CfgMACSources configured_sources =  cfg->getMACSources().get();
+    CfgMACSources configured_sources = cfg->getMACSources().get();
     ASSERT_EQ(2, configured_sources.size());
     EXPECT_EQ(HWAddr::HWADDR_SOURCE_DUID, configured_sources[0]);
     EXPECT_EQ(HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL, configured_sources[1]);
@@ -230,11 +230,11 @@ public:
 
                 if (config_pair.first == "hooks-libraries") {
                     HooksLibrariesParser hook_parser;
-                    HooksConfig&  libraries =
+                    HooksConfig& libraries =
                         CfgMgr::instance().getStagingCfg()->getHooksConfig();
                     hook_parser.parse(libraries, config_pair.second);
-                    libraries.verifyLibraries(config_pair.second->getPosition());
-                    libraries.loadLibraries();
+                    libraries.verifyLibraries(config_pair.second->getPosition(), false);
+                    libraries.loadLibraries(false);
                     continue;
                 }
             }
@@ -512,8 +512,8 @@ const SimpleDefaults ParseConfigTest::OPTION4_DEF_DEFAULTS = {
 const SimpleDefaults ParseConfigTest::OPTION6_DEFAULTS = {
     { "space",        Element::string,  "dhcp6"},
     { "csv-format",   Element::boolean, "true"},
-    { "always-send",  Element::boolean,"false"},
-    { "never-send",   Element::boolean,"false"}
+    { "always-send",  Element::boolean, "false"},
+    { "never-send",   Element::boolean, "false"}
 };
 
 /// This table defines default values for options in DHCPv4
@@ -1697,7 +1697,7 @@ TEST_F(ParseConfigTest, hexOptionData) {
         "0C 00 03 01 C0 00 03 02", // spaces
         "0C:00:03:01:C0:00:03:02", // colons
         "0x0C000301C0000302",  // 0x
-        "C 0 3 1 C0 0 3 02",  // one or two digit octets
+        "C 0 3 1 C0 0 3 02",   // one or two digit octets
         "0x0c000301C0000302"   // upper or lower case digits
     };
 
@@ -2891,7 +2891,7 @@ TEST_F(ParseConfigTest, defaultSubnet6) {
     EXPECT_EQ(D2ClientConfig::RCM_NEVER, subnet->getDdnsReplaceClientNameMode().get());
 
     EXPECT_TRUE(subnet->getDdnsGeneratedPrefix().unspecified());
-    EXPECT_EQ("", subnet->getDdnsGeneratedPrefix().get());
+    EXPECT_TRUE(subnet->getDdnsGeneratedPrefix().empty());
 
     EXPECT_TRUE(subnet->getDdnsQualifyingSuffix().unspecified());
     EXPECT_TRUE(subnet->getDdnsQualifyingSuffix().empty());
index e10dccd137e6a90b8f1bb6f02b8beb970c810bc9..607e90739175d2a2153f388e5efe3fee45290222 100644 (file)
@@ -106,7 +106,7 @@ TEST_F(DHCPQueueControlParserTest, validContent) {
             // Parsing config into a queue control should succeed.
             DHCPQueueControlParser parser;
             try {
-                queue_control = parser.parse(config_elems);
+                queue_control = parser.parse(config_elems, false);
             } catch (const std::exception& ex) {
                 ADD_FAILURE() << "parser threw an exception: " << ex.what();
             }
@@ -170,7 +170,7 @@ TEST_F(DHCPQueueControlParserTest, invalidContent) {
 
             // Parsing config into a queue control should succeed.
             DHCPQueueControlParser parser;
-            EXPECT_THROW(parser.parse(config_elems), DhcpConfigError);
+            EXPECT_THROW(parser.parse(config_elems, false), DhcpConfigError);
         }
     }
 }
@@ -193,18 +193,16 @@ TEST_F(DHCPQueueControlParserTest, multiThreading) {
     // Parse config.
     DHCPQueueControlParser parser;
     ConstElementPtr queue_control;
-    ASSERT_FALSE(MultiThreadingMgr::instance().getMode());
-    ASSERT_NO_THROW(queue_control = parser.parse(config_elems))
+    ASSERT_NO_THROW(queue_control = parser.parse(config_elems, false))
         << "parse fails, test is broken";
+
     // Verify that queue is enabled.
     ASSERT_TRUE(queue_control);
     ASSERT_TRUE(queue_control->get("enable-queue"));
     EXPECT_EQ("true", queue_control->get("enable-queue")->str());
 
     // Retry with multi-threading.
-    MultiThreadingTest mt(true);
-    ASSERT_TRUE(MultiThreadingMgr::instance().getMode());
-    ASSERT_NO_THROW(queue_control = parser.parse(config_elems));
+    ASSERT_NO_THROW(queue_control = parser.parse(config_elems, true));
     ASSERT_TRUE(queue_control);
     ASSERT_TRUE(queue_control->get("enable-queue"));
     EXPECT_EQ("false", queue_control->get("enable-queue")->str());
index 2272ccbe124268676dc0d78e1e7c6dc4d51c6c1b..b9196a8b888f37b4208ee1746a089e23c9b1ee02 100644 (file)
@@ -111,8 +111,6 @@ TEST_F(MultiThreadingConfigParserTest, validContent) {
             CfgMultiThreading::extract(multi_threading_config, enabled,
                                        thread_count, queue_size);
 
-            EXPECT_EQ(MultiThreadingMgr::instance().getMode(), enabled);
-
             EXPECT_TRUE(multi_threading_config->equals(*config_elems));
         }
     }
index c6bf9a2268a6bb227e702735ae2edbf736c2d54a..6fdd4136f784b3f8e23e4c449cde13fd710dcc58 100644 (file)
@@ -17,7 +17,8 @@ namespace isc {
 namespace hooks {
 
 void
-HooksConfig::verifyLibraries(const Element::Position& position) const {
+HooksConfig::verifyLibraries(const Element::Position& position,
+                             bool multi_threading_enabled) const {
     // The code used to follow this logic:
     //
     // Check if the list of libraries has changed.  If not, nothing is done
@@ -36,7 +37,8 @@ HooksConfig::verifyLibraries(const Element::Position& position) const {
 
     // Library list has changed, validate each of the libraries specified.
     vector<string> lib_names = isc::hooks::extractNames(libraries_);
-    vector<string> error_libs = HooksManager::validateLibraries(lib_names);
+    vector<string> error_libs = HooksManager::validateLibraries(lib_names,
+                                                                multi_threading_enabled);
     if (!error_libs.empty()) {
 
         // Construct the list of libraries in error for the message.
@@ -52,12 +54,12 @@ HooksConfig::verifyLibraries(const Element::Position& position) const {
 }
 
 void
-HooksConfig::loadLibraries() const {
+HooksConfig::loadLibraries(bool multi_threading_enabled) const {
     /// Commits the list of libraries to the configuration manager storage if
     /// the list of libraries has changed.
     /// @todo: Delete any stored CalloutHandles before reloading the
     /// libraries
-    if (!HooksManager::loadLibraries(libraries_)) {
+    if (!HooksManager::loadLibraries(libraries_, multi_threading_enabled)) {
         isc_throw(InvalidHooksLibraries,
                   "One or more hook libraries failed to load");
     }
index 837727e40e139081851e9f582a8a39d6a4b5dd1e..d0cdb67f5828590984581ff32aaaa5301228ce14 100644 (file)
@@ -72,8 +72,12 @@ public:
     /// It tries to validate all the libraries stored in libraries_.
     ///
     /// @param position position of the hooks-library map for error reporting
+    /// @param multi_threading_enabled The flag which indicates if MT is enabled
+    ///        (used to check hook libraries compatibility with MT).
+    ///
     /// @throw InvalidHooksLibraries if any issue is discovered.
-    void verifyLibraries(const isc::data::Element::Position& position) const;
+    void verifyLibraries(const isc::data::Element::Position& position,
+                         bool multi_threading_enabled) const;
 
     /// @brief Commits hooks libraries configuration.
     ///
@@ -83,8 +87,11 @@ public:
     /// different to those already loaded, this method loads the new set of
     /// libraries (and unloads the existing set).
     ///
+    /// @param multi_threading_enabled The flag which indicates if MT is enabled
+    ///        (used to check hook libraries compatibility with MT).
+    ///
     /// @throw InvalidHooksLibraries if the call to HooksManager fails.
-    void loadLibraries() const;
+    void loadLibraries(bool multi_threading_enabled) const;
 
     /// @brief Unparse a configuration object
     ///
@@ -102,7 +109,7 @@ private:
     isc::hooks::HookLibsCollection libraries_;
 };
 
-};
-};
+}  // namespace hooks
+}  // namespace isc
 
 #endif // HOOKS_CONFIG_H
index 82b741ed25dad5cd8fb533145a33159b46a1e4ef..a5faf768237069a7accf2656cab8d3f44efe557f 100644 (file)
@@ -31,7 +31,7 @@ HooksManager::HooksManager() : test_mode_(false) {
     // libraries, and get the CalloutManager.
     HookLibsCollection libraries;
     lm_collection_.reset(new LibraryManagerCollection(libraries));
-    lm_collection_->loadLibraries();
+    lm_collection_->loadLibraries(false);
     callout_manager_ = lm_collection_->getCalloutManager();
 }
 
@@ -94,7 +94,8 @@ HooksManager::callCommandHandlers(const std::string& command_name,
 // empty list.
 
 bool
-HooksManager::loadLibrariesInternal(const HookLibsCollection& libraries) {
+HooksManager::loadLibrariesInternal(const HookLibsCollection& libraries,
+                                    bool multi_threading_enabled) {
     if (test_mode_) {
         return (true);
     }
@@ -114,7 +115,7 @@ HooksManager::loadLibrariesInternal(const HookLibsCollection& libraries) {
     }
 
     // Load the libraries.
-    bool status = lm_collection_->loadLibraries();
+    bool status = lm_collection_->loadLibraries(multi_threading_enabled);
 
     if (status) {
         // ... and obtain the callout manager for them if successful.
@@ -129,8 +130,10 @@ HooksManager::loadLibrariesInternal(const HookLibsCollection& libraries) {
 }
 
 bool
-HooksManager::loadLibraries(const HookLibsCollection& libraries) {
-    return (getHooksManager().loadLibrariesInternal(libraries));
+HooksManager::loadLibraries(const HookLibsCollection& libraries,
+                            bool multi_threading_enabled) {
+    return (getHooksManager().loadLibrariesInternal(libraries,
+                                                    multi_threading_enabled));
 }
 
 // Unload the libraries.  This just deletes all internal objects (which will
@@ -162,7 +165,7 @@ HooksManager::unloadLibrariesInternal() {
     }
 
     // Load the empty set of libraries.
-    lm_collection_->loadLibraries();
+    lm_collection_->loadLibraries(false);
 
     // Get the CalloutManager.
     callout_manager_ = lm_collection_->getCalloutManager();
@@ -255,8 +258,10 @@ HooksManager::postCalloutsLibraryHandle() {
 // Validate libraries
 
 std::vector<std::string>
-HooksManager::validateLibraries(const std::vector<std::string>& libraries) {
-    return (LibraryManagerCollection::validateLibraries(libraries));
+HooksManager::validateLibraries(const std::vector<std::string>& libraries,
+                                bool multi_threading_enabled) {
+    return (LibraryManagerCollection::validateLibraries(libraries,
+                                                        multi_threading_enabled));
 }
 
 // Test mode
index 647e14a531dd193c15517b1e471aabdb0b200769..2ca717b0fc84039d17003487c1f0f10510f5712b 100644 (file)
@@ -66,12 +66,15 @@ public:
     /// @param libraries List of libraries to be loaded.  The order is
     ///        important, as it determines the order that callouts on the same
     ///        hook will be called.
+    /// @param multi_threading_enabled The flag which indicates if MT is enabled
+    ///        (used to check hook libraries compatibility with MT).
     ///
     /// @return true if all libraries loaded without a problem, false if one or
     ///        more libraries failed to load.  In the latter case, message will
     ///        be logged that give the reason.
     /// @throw LibrariesStillOpened when some libraries are already loaded.
-    static bool loadLibraries(const HookLibsCollection& libraries);
+    static bool loadLibraries(const HookLibsCollection& libraries,
+                              bool multi_threading_enabled = false);
 
     /// @brief Unload libraries
     ///
@@ -247,11 +250,13 @@ public:
     /// change is committed.
     ///
     /// @param libraries List of libraries to be validated.
+    /// @param multi_threading_enabled The flag which indicates if MT is enabled
+    ///        (used to check hook libraries compatibility with MT).
     ///
     /// @return An empty vector if all libraries validated.  Otherwise it
     ///         holds the names of the libraries that failed validation.
-    static std::vector<std::string> validateLibraries(
-                       const std::vector<std::string>& libraries);
+    static std::vector<std::string> validateLibraries(const std::vector<std::string>& libraries,
+                                                      bool multi_threading_enabled = false);
 
     /// Index numbers for pre-defined hooks.
     static const int CONTEXT_CREATE = ServerHooks::CONTEXT_CREATE;
@@ -379,27 +384,19 @@ private:
     /// but actually do the work on the singleton instance of the HooksManager.
     /// See the descriptions of the static methods for more details.
 
-    /// @brief Validate library list
-    ///
-    /// @param List of libraries to be validated.
-    ///
-    /// @return An empty string if all libraries validated.  Otherwise it is
-    ///         the name of the first library that failed validation.  The
-    ///         configuration code can return this to bindctl as an indication
-    ///         of the problem.
-    std::string validateLibrariesInternal(
-                       const std::vector<std::string>& libraries) const;
-
     /// @brief Load and reload libraries
     ///
     /// @param libraries List of libraries to be loaded.  The order is
     ///        important, as it determines the order that callouts on the same
     ///        hook will be called.
+    /// @param multi_threading_enabled The flag which indicates if MT is enabled
+    ///        (used to check hook libraries compatibility with MT).
     ///
     /// @return true if all libraries loaded without a problem, false if one or
     ///        more libraries failed to load.  In the latter case, message will
     ///        be logged that give the reason.
-    bool loadLibrariesInternal(const HookLibsCollection& libraries);
+    bool loadLibrariesInternal(const HookLibsCollection& libraries,
+                               bool multi_threading_enabled);
 
     /// @brief Unload libraries
     ///
index 447c9ebb883975df7cce5d10d27220547a8730b4..ac6b1091271a45f6219c40e29da9cadb361b9fef 100644 (file)
@@ -139,10 +139,10 @@ LibraryManager::checkVersion() const {
 // Check the multi-threading compatibility of the library
 
 bool
-LibraryManager::checkMultiThreadingCompatible() const {
+LibraryManager::checkMultiThreadingCompatible(bool multi_threading_enabled) const {
 
     // Compatible with single-threaded.
-    if (!util::MultiThreadingMgr::instance().getMode()) {
+    if (!multi_threading_enabled) {
         return (true);
     }
 
@@ -314,7 +314,7 @@ LibraryManager::prepareUnloadLibrary() {
 // The main library loading function.
 
 bool
-LibraryManager::loadLibrary() {
+LibraryManager::loadLibrary(bool multi_threading_enabled) {
     LOG_DEBUG(hooks_logger, HOOKS_DBG_TRACE, HOOKS_LIBRARY_LOADING)
         .arg(library_name_);
 
@@ -340,7 +340,7 @@ LibraryManager::loadLibrary() {
 
         // Library opened OK, see if a version function is present and if so,
         // check what value it returns. Check multi-threading compatibility.
-        if (checkVersion() && checkMultiThreadingCompatible()) {
+        if (checkVersion() && checkMultiThreadingCompatible(multi_threading_enabled)) {
             // Version OK, so now register the standard callouts and call the
             // library's load() function if present.
             registerStandardCallouts();
@@ -407,14 +407,14 @@ LibraryManager::unloadLibrary() {
 // method.
 
 bool
-LibraryManager::validateLibrary(const std::string& name) {
+LibraryManager::validateLibrary(const std::string& name, bool multi_threading_enabled) {
     // Instantiate a library manager for the validation.  We use the private
     // constructor as we don't supply a CalloutManager.
     LibraryManager manager(name);
 
     // Try to open it and, if we succeed, check the version.
     bool validated = manager.openLibrary() && manager.checkVersion() &&
-        manager.checkMultiThreadingCompatible();
+        manager.checkMultiThreadingCompatible(multi_threading_enabled);
 
     // Regardless of whether the version checked out, close the library. (This
     // is a no-op if the library failed to open.)
index f3a376fa627bf154a55302b51b00a829caf548df..cbf0880741a4060cf464837d5605d588414c9e0b 100644 (file)
@@ -103,10 +103,13 @@ public:
     /// returns the right number, and the multi-threading compatibility.
     ///
     /// @param name Name of the library to validate
+    /// @param multi_threading_enabled The flag which indicates if MT is enabled
+    ///        (used to check hook libraries compatibility with MT).
     ///
     /// @return true if the library validated, false if not.  If the library
     /// fails to validate, the reason for the failure is logged.
-    static bool validateLibrary(const std::string& name);
+    static bool validateLibrary(const std::string& name,
+                                bool multi_threading_enabled = false);
 
     /// @brief Loads a library
     ///
@@ -119,9 +122,12 @@ public:
     /// update the global logging dictionary with the log messages
     /// registered by the loaded library.
     ///
+    /// @param multi_threading_enabled The flag which indicates if MT is enabled
+    ///        (used to check hook libraries compatibility with MT).
+    ///
     /// @return true if the library loaded successfully, false otherwise.
     /// In the latter case, the library will be unloaded if possible.
-    bool loadLibrary();
+    bool loadLibrary(bool multi_threading_enabled = false);
 
     /// @brief Prepares library unloading
     ///
@@ -192,13 +198,16 @@ protected:
 
     /// @brief Check multi-threading compatibility
     ///
-    /// If the multi-threading mode is false returns true, else with
+    /// If the multi-threading mode is disabled returns true, else with
     /// the library open, accesses the "multi_threading_compatible()"
     /// function and returns false if not exists or has value 0, returns
     /// true otherwise.
     ///
+    /// @param multi_threading_enabled The flag which indicates if MT is enabled
+    ///        (used to check hook libraries compatibility with MT).
+    ///
     /// @return bool true if the check succeeded
-    bool checkMultiThreadingCompatible() const;
+    bool checkMultiThreadingCompatible(bool multi_threading_enabled) const;
 
     /// @brief Register standard callouts
     ///
index 6c32b76ce5ecaa6b1f28f307b61de8fdff7196b0..50262c1449de2cec8306d0db63dd14d06872926d 100644 (file)
@@ -50,7 +50,7 @@ LibraryManagerCollection::LibraryManagerCollection(const HookLibsCollection& lib
 // Load a set of libraries
 
 bool
-LibraryManagerCollection::loadLibraries() {
+LibraryManagerCollection::loadLibraries(bool multi_threading_enabled) {
 
     // There must be no libraries still in memory.
     if (!lib_managers_.empty()) {
@@ -90,7 +90,7 @@ LibraryManagerCollection::loadLibraries() {
         // libraries.  On failure, unload all currently loaded libraries,
         // leaving the object in the state it was in before loadLibraries was
         // called.
-        if (manager->loadLibrary()) {
+        if (manager->loadLibrary(multi_threading_enabled)) {
             lib_managers_.push_back(manager);
         } else {
             static_cast<void>(unloadLibraries());
@@ -136,12 +136,12 @@ LibraryManagerCollection::getLoadedLibraryCount() const {
 
 // Validate the libraries.
 std::vector<std::string>
-LibraryManagerCollection::validateLibraries(
-                          const std::vector<std::string>& libraries) {
+LibraryManagerCollection::validateLibraries(const std::vector<std::string>& libraries,
+                                            bool multi_threading_enabled) {
 
     std::vector<std::string> failures;
     for (size_t i = 0; i < libraries.size(); ++i) {
-        if (!LibraryManager::validateLibrary(libraries[i])) {
+        if (!LibraryManager::validateLibrary(libraries[i], multi_threading_enabled)) {
             failures.push_back(libraries[i]);
         }
     }
index 53a9669a49fac2a413a029aa2805b5b6780bd6d0..1aa28fe07ecf321595beed7f662e07e8da50c271 100644 (file)
@@ -90,9 +90,12 @@ public:
     /// to load, the loading is abandoned and all libraries loaded so far
     /// are unloaded.
     ///
+    /// @param multi_threading_enabled The flag which indicates if MT is enabled
+    ///        (used to check hook libraries compatibility with MT).
+    ///
     /// @return true if all libraries loaded, false if one or more failed t
     ////        load.
-    bool loadLibraries();
+    bool loadLibraries(bool multi_threading_enabled = false);
 
     /// @brief Get callout manager
     ///
@@ -137,12 +140,14 @@ public:
     /// exist, can be opened, that a "version" function is present in them, and
     /// that it returns the right number.  All errors are logged.
     ///
-    /// @param libraries List of libraries to validate
+    /// @param libraries List of libraries to validate.
+    /// @param multi_threading_enabled The flag which indicates if MT is enabled
+    ///        (used to check hook libraries compatibility with MT).
     ///
     /// @return Vector of libraries that failed to validate, or an empty vector
     ///         if all validated.
-    static std::vector<std::string>
-    validateLibraries(const std::vector<std::string>& libraries);
+    static std::vector<std::string> validateLibraries(const std::vector<std::string>& libraries,
+                                                      bool multi_threading_enabled = false);
 
     /// @brief Prepare libaries unloading
     ///
index c0174a41bf5f41100428e841346ca18627e93920..7629c7bf263e87ca0286339d5816c5ec7993b18e 100644 (file)
@@ -258,11 +258,10 @@ TEST_F(LibraryManagerTest, NoMultiThreadingCompatible) {
     EXPECT_TRUE(lib_manager.openLibrary());
 
     // Not multi-threading compatible: does not matter without MT.
-    EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible());
+    EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible(false));
 
     // Not multi-threading compatible: does matter with MT.
-    MultiThreadingMgr::instance().setMode(true);
-    EXPECT_FALSE(lib_manager.checkMultiThreadingCompatible());
+    EXPECT_FALSE(lib_manager.checkMultiThreadingCompatible(true));
 
     // Tidy up.
     EXPECT_TRUE(lib_manager.closeLibrary());
@@ -279,11 +278,10 @@ TEST_F(LibraryManagerTest, multiThreadingNotCompatible) {
     EXPECT_TRUE(lib_manager.openLibrary());
 
     // Not multi-threading compatible: does not matter without MT.
-    EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible());
+    EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible(false));
 
     // Not multi-threading compatible: does matter with MT.
-    MultiThreadingMgr::instance().setMode(true);
-    EXPECT_FALSE(lib_manager.checkMultiThreadingCompatible());
+    EXPECT_FALSE(lib_manager.checkMultiThreadingCompatible(true));
 
     // Tidy up.
     EXPECT_TRUE(lib_manager.closeLibrary());
@@ -300,11 +298,10 @@ TEST_F(LibraryManagerTest, multiThreadingCompatible) {
     EXPECT_TRUE(lib_manager.openLibrary());
 
     // Multi-threading compatible: does not matter without MT.
-    EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible());
+    EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible(false));
 
     // Multi-threading compatible: does matter with MT.
-    MultiThreadingMgr::instance().setMode(true);
-    EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible());
+    EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible(true));
 
     // Tidy up.
     EXPECT_TRUE(lib_manager.closeLibrary());
@@ -321,11 +318,10 @@ TEST_F(LibraryManagerTest, multiThreadingCompatibleException) {
     EXPECT_TRUE(lib_manager.openLibrary());
 
     // Throw exception: does not matter without MT.
-    EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible());
+    EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible(false));
 
     // Throw exception: does matter with MT.
-    MultiThreadingMgr::instance().setMode(true);
-    EXPECT_FALSE(lib_manager.checkMultiThreadingCompatible());
+    EXPECT_FALSE(lib_manager.checkMultiThreadingCompatible(true));
 
     // Tidy up.
     EXPECT_TRUE(lib_manager.closeLibrary());
@@ -695,18 +691,16 @@ TEST_F(LibraryManagerTest, validateLibraries) {
     EXPECT_TRUE(LibraryManager::validateLibrary(UNLOAD_CALLOUT_LIBRARY));
     EXPECT_TRUE(LibraryManager::validateLibrary(CALLOUT_PARAMS_LIBRARY));
 
-    MultiThreadingMgr::instance().setMode(true);
-
-    EXPECT_FALSE(LibraryManager::validateLibrary(BASIC_CALLOUT_LIBRARY));
-    EXPECT_TRUE(LibraryManager::validateLibrary(FULL_CALLOUT_LIBRARY));
-    EXPECT_FALSE(LibraryManager::validateLibrary(FRAMEWORK_EXCEPTION_LIBRARY));
-    EXPECT_FALSE(LibraryManager::validateLibrary(INCORRECT_VERSION_LIBRARY));
-    EXPECT_FALSE(LibraryManager::validateLibrary(LOAD_CALLOUT_LIBRARY));
-    EXPECT_FALSE(LibraryManager::validateLibrary(LOAD_ERROR_CALLOUT_LIBRARY));
-    EXPECT_FALSE(LibraryManager::validateLibrary(NOT_PRESENT_LIBRARY));
-    EXPECT_FALSE(LibraryManager::validateLibrary(NO_VERSION_LIBRARY));
-    EXPECT_FALSE(LibraryManager::validateLibrary(UNLOAD_CALLOUT_LIBRARY));
-    EXPECT_FALSE(LibraryManager::validateLibrary(CALLOUT_PARAMS_LIBRARY));
+    EXPECT_FALSE(LibraryManager::validateLibrary(BASIC_CALLOUT_LIBRARY, true));
+    EXPECT_TRUE(LibraryManager::validateLibrary(FULL_CALLOUT_LIBRARY, true));
+    EXPECT_FALSE(LibraryManager::validateLibrary(FRAMEWORK_EXCEPTION_LIBRARY, true));
+    EXPECT_FALSE(LibraryManager::validateLibrary(INCORRECT_VERSION_LIBRARY, true));
+    EXPECT_FALSE(LibraryManager::validateLibrary(LOAD_CALLOUT_LIBRARY, true));
+    EXPECT_FALSE(LibraryManager::validateLibrary(LOAD_ERROR_CALLOUT_LIBRARY, true));
+    EXPECT_FALSE(LibraryManager::validateLibrary(NOT_PRESENT_LIBRARY, true));
+    EXPECT_FALSE(LibraryManager::validateLibrary(NO_VERSION_LIBRARY, true));
+    EXPECT_FALSE(LibraryManager::validateLibrary(UNLOAD_CALLOUT_LIBRARY, true));
+    EXPECT_FALSE(LibraryManager::validateLibrary(CALLOUT_PARAMS_LIBRARY, true));
 }
 
 // Check that log messages are properly registered and unregistered.
index 6f41b5ad0295a59313a1708701c610cc0180698c..42385ed27edb634ad6427e7e7142306a3dc27011 100644 (file)
@@ -1949,14 +1949,6 @@ private:
 
 HttpClient::HttpClient(IOService& io_service, size_t thread_pool_size,
                        bool defer_thread_start /* = false */) {
-    if (thread_pool_size > 0) {
-        if (!MultiThreadingMgr::instance().getMode()) {
-            isc_throw(InvalidOperation,
-                      "HttpClient thread_pool_size must be zero"
-                      "when Kea core multi-threading is disabled");
-        }
-    }
-
     impl_.reset(new HttpClientImpl(io_service, thread_pool_size,
                                    defer_thread_start));
 }
index b483273563c040e551b2ed3f6d6b681df9db6946..e6b98556e6cbe5e3c25333d98d2328c3d52f8747 100644 (file)
@@ -844,12 +844,6 @@ TEST_F(MultiThreadingHttpClientTest, basics) {
     // Make sure destruction doesn't throw.
     ASSERT_NO_THROW_LOG(client.reset());
 
-    // Non-zero thread-pool-size means multi-threaded mode, should throw.
-    ASSERT_THROW_MSG(client.reset(new HttpClient(io_service_, 1)), InvalidOperation,
-                                  "HttpClient thread_pool_size must be zero"
-                                  "when Kea core multi-threading is disabled");
-    ASSERT_FALSE(client);
-
     // Enable Kea core multi-threading.
     MultiThreadingMgr::instance().setMode(true);