From 1fa4e4b6a43b1a5d33ba10209521d9aa22a7c630 Mon Sep 17 00:00:00 2001 From: Razvan Becheriu Date: Fri, 24 Mar 2023 11:25:57 +0200 Subject: [PATCH] [#2799] disable MT on destructor (UT do not use run) --- src/bin/dhcp4/ctrl_dhcp4_srv.cc | 1 + src/bin/dhcp4/tests/kea_controller_unittest.cc | 4 ++-- src/bin/dhcp6/ctrl_dhcp6_srv.cc | 1 + src/bin/dhcp6/tests/kea_controller_unittest.cc | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 436f2d982a..db54107759 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -1208,6 +1208,7 @@ void ControlledDhcpv4Srv::shutdownServer(int exit_value) { ControlledDhcpv4Srv::~ControlledDhcpv4Srv() { try { + MultiThreadingMgr::instance().apply(false, 0, 0); LeaseMgrFactory::destroy(); HostMgr::create(); cleanup(); diff --git a/src/bin/dhcp4/tests/kea_controller_unittest.cc b/src/bin/dhcp4/tests/kea_controller_unittest.cc index 7578833c0d..d164a23678 100644 --- a/src/bin/dhcp4/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp4/tests/kea_controller_unittest.cc @@ -230,10 +230,10 @@ public: void runTimersWithTimeout(const IOServicePtr& io_service, const long timeout_ms, std::function cond = std::function()) { IntervalTimer timer(*io_service); - bool stopped = false; + std::atomic stopped = false; timer.setup([&io_service, &stopped]() { - io_service->stop(); stopped = true; + io_service->stop(); }, timeout_ms, IntervalTimer::ONE_SHOT); // Run as long as the timeout hasn't occurred and the interrupting diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index b4d9e0d2ed..710bd18ad2 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -1228,6 +1228,7 @@ void ControlledDhcpv6Srv::shutdownServer(int exit_value) { ControlledDhcpv6Srv::~ControlledDhcpv6Srv() { try { + MultiThreadingMgr::instance().apply(false, 0, 0); LeaseMgrFactory::destroy(); HostMgr::create(); cleanup(); diff --git a/src/bin/dhcp6/tests/kea_controller_unittest.cc b/src/bin/dhcp6/tests/kea_controller_unittest.cc index a124913272..d932d42236 100644 --- a/src/bin/dhcp6/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp6/tests/kea_controller_unittest.cc @@ -217,10 +217,10 @@ public: void runTimersWithTimeout(const IOServicePtr& io_service, const long timeout_ms, std::function cond = std::function()) { IntervalTimer timer(*io_service); - bool stopped = false; + std::atomic stopped = false; timer.setup([&io_service, &stopped]() { - io_service->stop(); stopped = true; + io_service->stop(); }, timeout_ms, IntervalTimer::ONE_SHOT); // Run as long as the timeout hasn't occurred and the interrupting -- 2.47.3