From: Razvan Becheriu Date: Fri, 24 Mar 2023 09:25:57 +0000 (+0200) Subject: [#2799] disable MT on destructor (UT do not use run) X-Git-Tag: Kea-2.3.6~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1fa4e4b6a43b1a5d33ba10209521d9aa22a7c630;p=thirdparty%2Fkea.git [#2799] disable MT on destructor (UT do not use run) --- 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