diff options
author | Razvan Becheriu <razvan@isc.org> | 2024-03-27 10:44:03 +0100 |
---|---|---|
committer | Razvan Becheriu <razvan@isc.org> | 2024-04-04 07:26:51 +0200 |
commit | 3127326ff8f966e86210b58dd0ee5eef230f52a2 (patch) | |
tree | 84dc2cb3c5d2cfdea969c2f315cc52f1ed857da1 | |
parent | [#3281] use shared_from_this (diff) | |
download | kea-3127326ff8f966e86210b58dd0ee5eef230f52a2.tar.xz kea-3127326ff8f966e86210b58dd0ee5eef230f52a2.zip |
[#3281] stop service just in case it was still running
51 files changed, 97 insertions, 5 deletions
diff --git a/src/bin/agent/tests/ca_command_mgr_unittests.cc b/src/bin/agent/tests/ca_command_mgr_unittests.cc index 05ec8c7bc7..bd25e58cbf 100644 --- a/src/bin/agent/tests/ca_command_mgr_unittests.cc +++ b/src/bin/agent/tests/ca_command_mgr_unittests.cc @@ -248,6 +248,7 @@ public: // We have some cancelled operations for which we need to invoke the // handlers with the operation_aborted error code. + getIOService()->stop(); getIOService()->restart(); getIOService()->poll(); @@ -413,6 +414,7 @@ TEST_F(CtrlAgentCommandMgrTest, forwardListCommands) { // We have some cancelled operations for which we need to invoke the // handlers with the operation_aborted error code. + getIOService()->stop(); getIOService()->restart(); getIOService()->poll(); diff --git a/src/bin/agent/tests/ca_process_unittests.cc b/src/bin/agent/tests/ca_process_unittests.cc index e263e594f8..15b414e4b7 100644 --- a/src/bin/agent/tests/ca_process_unittests.cc +++ b/src/bin/agent/tests/ca_process_unittests.cc @@ -86,6 +86,7 @@ TEST_F(CtrlAgentProcessTest, shutdown) { elapsed.total_milliseconds() <= 400); timer.cancel(); + getIOService()->stop(); getIOService()->restart(); try { getIOService()->poll(); diff --git a/src/bin/d2/d2_process.cc b/src/bin/d2/d2_process.cc index 40c436d59f..134498a457 100644 --- a/src/bin/d2/d2_process.cc +++ b/src/bin/d2/d2_process.cc @@ -440,6 +440,7 @@ D2Process::reconfigureQueueMgr() { D2Process::~D2Process() { queue_mgr_->stopListening(); + getIOService()->stop(); getIOService()->restart(); try { getIOService()->poll(); diff --git a/src/bin/d2/tests/d2_process_unittests.cc b/src/bin/d2/tests/d2_process_unittests.cc index 35727b814a..83ae400129 100644 --- a/src/bin/d2/tests/d2_process_unittests.cc +++ b/src/bin/d2/tests/d2_process_unittests.cc @@ -585,6 +585,7 @@ TEST_F(D2ProcessTest, normalShutdown) { elapsed.total_milliseconds() <= 2200); timer.cancel(); + getIOService()->stop(); getIOService()->restart(); try { getIOService()->poll(); @@ -616,6 +617,7 @@ TEST_F(D2ProcessTest, fatalErrorShutdown) { elapsed.total_milliseconds() <= 2200); timer.cancel(); + getIOService()->stop(); getIOService()->restart(); try { getIOService()->poll(); diff --git a/src/bin/d2/tests/d2_queue_mgr_unittests.cc b/src/bin/d2/tests/d2_queue_mgr_unittests.cc index 93f4166f3c..16d9998567 100644 --- a/src/bin/d2/tests/d2_queue_mgr_unittests.cc +++ b/src/bin/d2/tests/d2_queue_mgr_unittests.cc @@ -250,6 +250,7 @@ public: sender_->stopSending(); queue_mgr_->stopListening(); test_timer_.cancel(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/bin/d2/tests/d2_update_mgr_unittests.cc b/src/bin/d2/tests/d2_update_mgr_unittests.cc index 0360a299c8..71ba0fb277 100644 --- a/src/bin/d2/tests/d2_update_mgr_unittests.cc +++ b/src/bin/d2/tests/d2_update_mgr_unittests.cc @@ -85,6 +85,7 @@ public: if (server_) { server_->stop(); } + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 51a9e47352..088b4b0222 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -706,6 +706,7 @@ Dhcpv4Srv::~Dhcpv4Srv() { } LOG_ERROR(dhcp4_logger, DHCP4_SRV_UNLOAD_LIBRARIES_ERROR).arg(msg); } + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/bin/dhcp4/tests/kea_controller_unittest.cc b/src/bin/dhcp4/tests/kea_controller_unittest.cc index ab8d62ef72..db1fc55a44 100644 --- a/src/bin/dhcp4/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp4/tests/kea_controller_unittest.cc @@ -242,6 +242,7 @@ public: while (!stopped && (!cond || !cond())) { io_service->runOne(); } + io_service->stop(); io_service->restart(); } diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 8639625860..dc0e8c086f 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -302,6 +302,7 @@ Dhcpv6Srv::~Dhcpv6Srv() { } LOG_ERROR(dhcp6_logger, DHCP6_SRV_UNLOAD_LIBRARIES_ERROR).arg(msg); } + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.h b/src/bin/dhcp6/tests/dhcp6_test_utils.h index 57d2894bc3..9b13230ddf 100644 --- a/src/bin/dhcp6/tests/dhcp6_test_utils.h +++ b/src/bin/dhcp6/tests/dhcp6_test_utils.h @@ -214,7 +214,7 @@ public: virtual ~NakedDhcpv6Srv() { // Close the lease database isc::dhcp::LeaseMgrFactory::destroy(); - + getIOService()->stop(); getIOService()->restart(); try { getIOService()->poll(); diff --git a/src/bin/dhcp6/tests/kea_controller_unittest.cc b/src/bin/dhcp6/tests/kea_controller_unittest.cc index 7c47f7aee3..b3afbd4f77 100644 --- a/src/bin/dhcp6/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp6/tests/kea_controller_unittest.cc @@ -227,6 +227,7 @@ public: while (!stopped && (!cond || !cond())) { io_service->runOne(); } + io_service->stop(); io_service->restart(); } diff --git a/src/bin/netconf/http_control_socket.cc b/src/bin/netconf/http_control_socket.cc index 3e7010f880..aa69a5054e 100644 --- a/src/bin/netconf/http_control_socket.cc +++ b/src/bin/netconf/http_control_socket.cc @@ -102,6 +102,7 @@ HttpControlSocket::sendCommand(ConstElementPtr command) { io_service->run(); client.stop(); + io_service->stop(); io_service->restart(); try { io_service->poll(); diff --git a/src/bin/netconf/tests/control_socket_unittests.cc b/src/bin/netconf/tests/control_socket_unittests.cc index ec038641fe..3dedb20c56 100644 --- a/src/bin/netconf/tests/control_socket_unittests.cc +++ b/src/bin/netconf/tests/control_socket_unittests.cc @@ -158,6 +158,7 @@ public: thread_.reset(); } removeUnixSocketFile(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -529,6 +530,7 @@ public: if (listener_) { listener_->stop(); } + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/bin/netconf/tests/netconf_process_unittests.cc b/src/bin/netconf/tests/netconf_process_unittests.cc index 436deba415..563dc3df50 100644 --- a/src/bin/netconf/tests/netconf_process_unittests.cc +++ b/src/bin/netconf/tests/netconf_process_unittests.cc @@ -81,6 +81,7 @@ TEST_F(NetconfProcessTest, shutdown) { EXPECT_TRUE(elapsed.total_milliseconds() >= 100 && elapsed.total_milliseconds() <= 400); timer.cancel(); + getIOService()->stop(); getIOService()->restart(); try { getIOService()->poll(); diff --git a/src/bin/netconf/tests/netconf_unittests.cc b/src/bin/netconf/tests/netconf_unittests.cc index 8bceac0b69..6b602553f2 100644 --- a/src/bin/netconf/tests/netconf_unittests.cc +++ b/src/bin/netconf/tests/netconf_unittests.cc @@ -130,6 +130,7 @@ public: responses_.clear(); removeUnixSocketFile(); SysrepoSetup::cleanSharedMemory(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/hooks/dhcp/high_availability/ha_service.cc b/src/hooks/dhcp/high_availability/ha_service.cc index 3ec6d8ca15..c295f91931 100644 --- a/src/hooks/dhcp/high_availability/ha_service.cc +++ b/src/hooks/dhcp/high_availability/ha_service.cc @@ -2450,6 +2450,7 @@ HAService::synchronize(std::string& status_message, const std::string& server_na client.stop(); + io_service->stop(); io_service->restart(); try { io_service->poll(); @@ -2596,6 +2597,7 @@ HAService::sendLeaseUpdatesFromBacklog() { client.stop(); + io_service->stop(); io_service->restart(); try { io_service->poll(); @@ -2683,6 +2685,7 @@ HAService::sendHAReset() { client.stop(); + io_service->stop(); io_service->restart(); try { io_service->poll(); @@ -2850,6 +2853,7 @@ HAService::processMaintenanceStart() { client.stop(); + io_service->stop(); io_service->restart(); try { io_service->poll(); @@ -2972,6 +2976,7 @@ HAService::processMaintenanceCancel() { client.stop(); + io_service->stop(); io_service->restart(); try { io_service->poll(); diff --git a/src/hooks/dhcp/high_availability/tests/ha_impl_unittest.cc b/src/hooks/dhcp/high_availability/tests/ha_impl_unittest.cc index b509ac1e6c..5bda9f456f 100644 --- a/src/hooks/dhcp/high_availability/tests/ha_impl_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/ha_impl_unittest.cc @@ -80,6 +80,7 @@ public: /// @brief Destructor. ~HAImplTest() { + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -87,6 +88,7 @@ public: } ha_impl_.reset(); test_ha_impl_.reset(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -126,12 +128,14 @@ public: checkAnswer(response, CONTROL_RESULT_ERROR, expected_response); callout_handle.reset(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); } catch (...) { } ha_impl_.reset(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/hooks/dhcp/high_availability/tests/ha_mt_unittest.cc b/src/hooks/dhcp/high_availability/tests/ha_mt_unittest.cc index 36ca35e439..89564f370f 100644 --- a/src/hooks/dhcp/high_availability/tests/ha_mt_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/ha_mt_unittest.cc @@ -134,8 +134,12 @@ public: /// /// Stops all test servers. ~HAMtServiceTest() { + io_service_->stop(); io_service_->restart(); - io_service_->poll(); + try { + io_service_->poll(); + } catch (...) { + } MultiThreadingMgr::instance().setMode(false); CmdResponseCreator::command_accept_list_.clear(); } diff --git a/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc b/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc index e3278814a4..1198f82e6c 100644 --- a/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc @@ -625,6 +625,7 @@ public: listener_->stop(); listener2_->stop(); listener3_->stop(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -1512,6 +1513,7 @@ public: // Change the partner's response to success. factory2_->getResponseCreator()->setControlResult(CONTROL_RESULT_SUCCESS); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -5608,6 +5610,7 @@ public: } ~HAServiceStateMachineTest() { + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/hooks/dhcp/high_availability/tests/ha_test.cc b/src/hooks/dhcp/high_availability/tests/ha_test.cc index 2e875065ff..cd3e9f4371 100644 --- a/src/hooks/dhcp/high_availability/tests/ha_test.cc +++ b/src/hooks/dhcp/high_availability/tests/ha_test.cc @@ -59,6 +59,7 @@ HATest::~HATest() { if (timer_) { timer_->cancel(); } + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -79,6 +80,7 @@ HATest::startHAService() { void HATest::runIOService(long ms) { + io_service_->stop(); io_service_->restart(); timer_.reset(new IntervalTimer(io_service_)); timer_->setup(std::bind(&IOService::stop, io_service_), ms, @@ -91,6 +93,7 @@ HATest::runIOService(long ms) { void HATest::runIOService(long ms, std::function<bool()> stop_condition) { + io_service_->stop(); io_service_->restart(); timer_.reset(new IntervalTimer(io_service_)); bool timeout = false; @@ -106,6 +109,7 @@ HATest::runIOService(long ms, std::function<bool()> stop_condition) { boost::shared_ptr<std::thread> HATest::runIOServiceInThread() { + io_service_->stop(); io_service_->restart(); bool running = false; diff --git a/src/lib/asiodns/tests/io_fetch_unittest.cc b/src/lib/asiodns/tests/io_fetch_unittest.cc index 4fe94d421b..66dc67ab5a 100644 --- a/src/lib/asiodns/tests/io_fetch_unittest.cc +++ b/src/lib/asiodns/tests/io_fetch_unittest.cc @@ -157,6 +157,7 @@ public: virtual ~IOFetchTest() { shutdown_ = true; timer_.cancel(); + service_->stop(); service_->restart(); try { service_->poll(); diff --git a/src/lib/asiolink/tests/interval_timer_unittest.cc b/src/lib/asiolink/tests/interval_timer_unittest.cc index 214dd4da04..c1390519b4 100644 --- a/src/lib/asiolink/tests/interval_timer_unittest.cc +++ b/src/lib/asiolink/tests/interval_timer_unittest.cc @@ -29,6 +29,7 @@ protected: timer_cancel_success_(false) { } ~IntervalTimerTest() { + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/lib/asiolink/tests/process_spawn_unittest.cc b/src/lib/asiolink/tests/process_spawn_unittest.cc index ea7d386bbb..63355fb8de 100644 --- a/src/lib/asiolink/tests/process_spawn_unittest.cc +++ b/src/lib/asiolink/tests/process_spawn_unittest.cc @@ -68,6 +68,7 @@ public: io_signal_set_->remove(SIGCHLD); io_signal_set_.reset(); // Make sure the cancel handler for the IOSignalSet is called. + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/lib/asiolink/tests/tcp_acceptor_unittest.cc b/src/lib/asiolink/tests/tcp_acceptor_unittest.cc index 19d39e815b..ebee8a371e 100644 --- a/src/lib/asiolink/tests/tcp_acceptor_unittest.cc +++ b/src/lib/asiolink/tests/tcp_acceptor_unittest.cc @@ -221,6 +221,7 @@ public: virtual ~TCPAcceptorTest() { running_ = false; test_timer_.cancel(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/lib/asiolink/tests/tls_acceptor_unittest.cc b/src/lib/asiolink/tests/tls_acceptor_unittest.cc index 199c245366..aa319619fb 100644 --- a/src/lib/asiolink/tests/tls_acceptor_unittest.cc +++ b/src/lib/asiolink/tests/tls_acceptor_unittest.cc @@ -228,6 +228,7 @@ public: virtual ~TLSAcceptorTest() { running_ = false; test_timer_.cancel(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/lib/asiolink/tests/tls_unittest.cc b/src/lib/asiolink/tests/tls_unittest.cc index effbe19b14..a045bc59dc 100644 --- a/src/lib/asiolink/tests/tls_unittest.cc +++ b/src/lib/asiolink/tests/tls_unittest.cc @@ -422,6 +422,7 @@ public: /// @brief Destructor. virtual ~TLSTest() { + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/lib/asiolink/tests/unix_domain_socket_unittest.cc b/src/lib/asiolink/tests/unix_domain_socket_unittest.cc index 4ed5c127a6..37abacd77a 100644 --- a/src/lib/asiolink/tests/unix_domain_socket_unittest.cc +++ b/src/lib/asiolink/tests/unix_domain_socket_unittest.cc @@ -48,6 +48,7 @@ public: virtual ~UnixDomainSocketTest() { removeUnixSocketFile(); test_socket_.reset(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/lib/config/cmd_http_listener.cc b/src/lib/config/cmd_http_listener.cc index ed54552260..a516617d0c 100644 --- a/src/lib/config/cmd_http_listener.cc +++ b/src/lib/config/cmd_http_listener.cc @@ -92,11 +92,13 @@ CmdHttpListener::start() { } if (thread_io_service_) { + thread_io_service_->stop(); thread_io_service_->restart(); try { thread_io_service_->poll(); } catch (...) { } + thread_io_service_->stop(); } // Get rid of the thread pool. @@ -150,11 +152,13 @@ CmdHttpListener::stop() { // Stop the listener. http_listener_->stop(); + thread_io_service_->stop(); thread_io_service_->restart(); try { thread_io_service_->poll(); } catch (...) { } + thread_io_service_->stop(); // Get rid of the thread pool. thread_pool_.reset(); diff --git a/src/lib/config/tests/client_connection_unittests.cc b/src/lib/config/tests/client_connection_unittests.cc index 8684beeb36..6e508a6f5c 100644 --- a/src/lib/config/tests/client_connection_unittests.cc +++ b/src/lib/config/tests/client_connection_unittests.cc @@ -46,6 +46,7 @@ public: removeUnixSocketFile(); conn_.reset(); test_socket_.reset(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/lib/config/tests/cmd_http_listener_unittests.cc b/src/lib/config/tests/cmd_http_listener_unittests.cc index a7d34b213a..8e407583cb 100644 --- a/src/lib/config/tests/cmd_http_listener_unittests.cc +++ b/src/lib/config/tests/cmd_http_listener_unittests.cc @@ -81,6 +81,7 @@ public: } test_timer_.cancel(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -198,7 +199,7 @@ public: // Loop until the clients are done, an error occurs, or the time runs out. size_t num_done = 0; while (num_done != request_limit) { - // Always call restart() before we call run(); + io_service_->stop(); io_service_->restart(); // Run until a client stops the service. diff --git a/src/lib/d2srv/tests/dns_client_unittests.cc b/src/lib/d2srv/tests/dns_client_unittests.cc index f006043362..864acc3587 100644 --- a/src/lib/d2srv/tests/dns_client_unittests.cc +++ b/src/lib/d2srv/tests/dns_client_unittests.cc @@ -127,6 +127,7 @@ public: virtual ~DNSClientTest() { test_timer_.cancel(); dns_client_->stop(); + service_->stop(); service_->restart(); try { service_->poll(); @@ -450,6 +451,7 @@ public: // Since the callback, operator(), calls stop() on the io_service, // we must reset it in order for subsequent calls to run() or // runOne() to work. + service_->stop(); service_->restart(); try { service_->poll(); @@ -506,6 +508,7 @@ public: // Since the callback, operator(), calls stop() on the io_service, // we must reset it in order for subsequent calls to run() or // runOne() to work. + service_->stop(); service_->restart(); try { service_->poll(); diff --git a/src/lib/d2srv/tests/nc_trans_unittests.cc b/src/lib/d2srv/tests/nc_trans_unittests.cc index 7c978e5201..2f4a1ba9ce 100644 --- a/src/lib/d2srv/tests/nc_trans_unittests.cc +++ b/src/lib/d2srv/tests/nc_trans_unittests.cc @@ -279,6 +279,7 @@ public: virtual ~NameChangeTransactionTest() { timer_->cancel(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/lib/d2srv/testutils/nc_test_utils.cc b/src/lib/d2srv/testutils/nc_test_utils.cc index c9b8a671d8..066af32212 100644 --- a/src/lib/d2srv/testutils/nc_test_utils.cc +++ b/src/lib/d2srv/testutils/nc_test_utils.cc @@ -227,6 +227,7 @@ TimedIO::TimedIO() TimedIO::~TimedIO() { timer_->cancel(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/lib/dhcp_ddns/ncr_io.cc b/src/lib/dhcp_ddns/ncr_io.cc index 70ded4bb8c..109fa8874f 100644 --- a/src/lib/dhcp_ddns/ncr_io.cc +++ b/src/lib/dhcp_ddns/ncr_io.cc @@ -231,6 +231,7 @@ NameChangeSender::stopSending() { if (io_service_) { try { + io_service_->stop(); io_service_->restart(); io_service_->poll(); } catch (const std::exception& ex) { diff --git a/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc b/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc index b7063ebb81..904af5b919 100644 --- a/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc +++ b/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc @@ -202,6 +202,7 @@ public: virtual ~NameChangeUDPListenerTest() { test_timer_.cancel(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -1037,6 +1038,7 @@ public: ~NameChangeUDPTest() { test_timer_.cancel(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/lib/dhcpsrv/d2_client_mgr.cc b/src/lib/dhcpsrv/d2_client_mgr.cc index 022e01212c..a1068d42d5 100644 --- a/src/lib/dhcpsrv/d2_client_mgr.cc +++ b/src/lib/dhcpsrv/d2_client_mgr.cc @@ -314,6 +314,7 @@ D2ClientMgr::stopSender() { } if (private_io_service_) { + private_io_service_->stop(); private_io_service_->restart(); try { private_io_service_->poll(); diff --git a/src/lib/dhcpsrv/tests/cfg_expiration_unittest.cc b/src/lib/dhcpsrv/tests/cfg_expiration_unittest.cc index 318d6275d1..d37f0c1620 100644 --- a/src/lib/dhcpsrv/tests/cfg_expiration_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_expiration_unittest.cc @@ -310,6 +310,7 @@ public: /// timers. virtual ~CfgExpirationTimersTest() { cleanupTimerMgr(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -333,6 +334,7 @@ public: }, timeout_ms, IntervalTimer::ONE_SHOT); io_service_->run(); + io_service_->stop(); io_service_->restart(); } diff --git a/src/lib/dhcpsrv/tests/cfg_iface_unittest.cc b/src/lib/dhcpsrv/tests/cfg_iface_unittest.cc index 8b9e97d2f4..1f82e8cca1 100644 --- a/src/lib/dhcpsrv/tests/cfg_iface_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_iface_unittest.cc @@ -122,6 +122,7 @@ CfgIfaceTest::doWait(const long timeout) { io_service_->stop(); }, timeout, asiolink::IntervalTimer::ONE_SHOT); io_service_->run(); + io_service_->stop(); io_service_->restart(); } diff --git a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc index 89d6790204..7e2c656017 100644 --- a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc @@ -165,6 +165,7 @@ public: // Disable multi-threading. MultiThreadingMgr::instance().setMode(false); + getIOService()->stop(); getIOService()->restart(); try { getIOService()->poll(); @@ -254,6 +255,7 @@ public: }, ms, IntervalTimer::ONE_SHOT); io_service_->run(); + io_service_->stop(); io_service_->restart(); } @@ -281,6 +283,7 @@ public: }, 1, IntervalTimer::REPEATING); io_service_->run(); + io_service_->stop(); io_service_->restart(); return (!elapsed); } diff --git a/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc b/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc index c991b5577a..284ca8c199 100644 --- a/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc @@ -147,6 +147,7 @@ void TimerMgrTest::TearDown() { // Remove all timers. timer_mgr_->unregisterTimers(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -175,6 +176,7 @@ TimerMgrTest::doWait(const long timeout, const bool /*call_receive*/) { io_service_->stop(); }, timeout, IntervalTimer::ONE_SHOT); io_service_->run(); + io_service_->stop(); io_service_->restart(); } diff --git a/src/lib/http/client.cc b/src/lib/http/client.cc index 7a8f4f57be..20ccbc4966 100644 --- a/src/lib/http/client.cc +++ b/src/lib/http/client.cc @@ -1847,6 +1847,7 @@ public: } if (thread_io_service_) { + thread_io_service_->stop(); thread_io_service_->restart(); try { thread_io_service_->poll(); diff --git a/src/lib/http/tests/client_mt_unittests.cc b/src/lib/http/tests/client_mt_unittests.cc index ea15dc0fac..7a29ea37c3 100644 --- a/src/lib/http/tests/client_mt_unittests.cc +++ b/src/lib/http/tests/client_mt_unittests.cc @@ -218,6 +218,7 @@ public: } test_timer_.cancel(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -243,7 +244,7 @@ public: /// have been carried out or the test fails. void runIOService(size_t request_limit) { while (getRRCount() < request_limit) { - // Always call reset() before we call run(); + io_service_->stop(); io_service_->restart(); // Run until a client stops the service. diff --git a/src/lib/http/tests/connection_pool_unittests.cc b/src/lib/http/tests/connection_pool_unittests.cc index 810f850357..ac0fac5bda 100644 --- a/src/lib/http/tests/connection_pool_unittests.cc +++ b/src/lib/http/tests/connection_pool_unittests.cc @@ -114,6 +114,7 @@ public: /// @brief Destructor. ~HttpConnectionPoolTest() { + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/lib/http/tests/server_client_unittests.cc b/src/lib/http/tests/server_client_unittests.cc index c963404281..62cd2f9717 100644 --- a/src/lib/http/tests/server_client_unittests.cc +++ b/src/lib/http/tests/server_client_unittests.cc @@ -413,6 +413,7 @@ public: client->close(); } test_timer_.cancel(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -449,6 +450,7 @@ public: /// @param timeout Optional value specifying for how long the io service /// should be ran. void runIOService(long timeout = 0) { + io_service_->stop(); io_service_->restart(); if (timeout > 0) { @@ -457,6 +459,7 @@ public: timeout, IntervalTimer::ONE_SHOT); } io_service_->run(); + io_service_->stop(); io_service_->restart(); io_service_->poll(); } @@ -1027,6 +1030,7 @@ public: listener_.stop(); listener2_.stop(); listener3_.stop(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/lib/http/tests/tls_client_unittests.cc b/src/lib/http/tests/tls_client_unittests.cc index 03d57ef0f4..dcba531ee4 100644 --- a/src/lib/http/tests/tls_client_unittests.cc +++ b/src/lib/http/tests/tls_client_unittests.cc @@ -236,6 +236,7 @@ public: /// @brief Destructor. virtual ~HttpListenerTest() { test_timer_.cancel(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -260,6 +261,7 @@ public: /// @param timeout Optional value specifying for how long the io service /// should be ran (ms). void runIOService(long timeout = 0) { + io_service_->stop(); io_service_->restart(); if (timeout > 0) { @@ -268,6 +270,7 @@ public: timeout, IntervalTimer::ONE_SHOT); } io_service_->run(); + io_service_->stop(); io_service_->restart(); io_service_->poll(); } diff --git a/src/lib/http/tests/tls_server_unittests.cc b/src/lib/http/tests/tls_server_unittests.cc index cca66ac8f1..7d98a81e45 100644 --- a/src/lib/http/tests/tls_server_unittests.cc +++ b/src/lib/http/tests/tls_server_unittests.cc @@ -659,6 +659,7 @@ public: client->close(); } test_timer_.cancel(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -696,6 +697,7 @@ public: /// @param timeout Optional value specifying for how long the io service /// should be ran. void runIOService(long timeout = 0) { + io_service_->stop(); io_service_->restart(); if (timeout > 0) { @@ -704,6 +706,7 @@ public: timeout, IntervalTimer::ONE_SHOT); } io_service_->run(); + io_service_->stop(); io_service_->restart(); io_service_->poll(); } diff --git a/src/lib/process/d_process.h b/src/lib/process/d_process.h index f7bee855ae..8926379db2 100644 --- a/src/lib/process/d_process.h +++ b/src/lib/process/d_process.h @@ -146,6 +146,7 @@ public: /// @brief Destructor virtual ~DProcessBase() { + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); diff --git a/src/lib/tcp/mt_tcp_listener_mgr.cc b/src/lib/tcp/mt_tcp_listener_mgr.cc index cacc34285a..5b71d622d1 100644 --- a/src/lib/tcp/mt_tcp_listener_mgr.cc +++ b/src/lib/tcp/mt_tcp_listener_mgr.cc @@ -88,11 +88,13 @@ MtTcpListenerMgr::start() { } if (thread_io_service_) { + thread_io_service_->stop(); thread_io_service_->restart(); try { thread_io_service_->poll(); } catch (...) { } + thread_io_service_->stop(); } // Get rid of the thread pool. @@ -146,11 +148,13 @@ MtTcpListenerMgr::stop() { // Stop the listener. tcp_listener_->stop(); + thread_io_service_->stop(); thread_io_service_->restart(); try { thread_io_service_->poll(); } catch (...) { } + thread_io_service_->stop(); // Get rid of the thread pool. thread_pool_.reset(); diff --git a/src/lib/tcp/tests/mt_tcp_listener_mgr_unittests.cc b/src/lib/tcp/tests/mt_tcp_listener_mgr_unittests.cc index 80be061708..58c394afe7 100644 --- a/src/lib/tcp/tests/mt_tcp_listener_mgr_unittests.cc +++ b/src/lib/tcp/tests/mt_tcp_listener_mgr_unittests.cc @@ -75,6 +75,7 @@ public: } test_timer_.cancel(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -233,7 +234,7 @@ public: // Loop until the clients are done, an error occurs, or the time runs out. size_t num_done = 0; while (num_done != request_limit) { - // Always call restart() before we call run(); + io_service_->stop(); io_service_->restart(); // Run until a client stops the service. diff --git a/src/lib/tcp/tests/tcp_listener_unittests.cc b/src/lib/tcp/tests/tcp_listener_unittests.cc index e9deff3e8d..5396c8f8a4 100644 --- a/src/lib/tcp/tests/tcp_listener_unittests.cc +++ b/src/lib/tcp/tests/tcp_listener_unittests.cc @@ -81,6 +81,7 @@ public: } test_timer_.cancel(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -157,6 +158,7 @@ public: /// @param timeout Optional value specifying for how long the io service /// should be ran. void runIOService(long timeout = 0) { + io_service_->stop(); io_service_->restart(); if (timeout > 0) { @@ -166,6 +168,7 @@ public: IntervalTimer::ONE_SHOT); } io_service_->run(); + io_service_->stop(); io_service_->restart(); io_service_->poll(); } diff --git a/src/lib/tcp/tests/tls_listener_unittests.cc b/src/lib/tcp/tests/tls_listener_unittests.cc index c4d1fadf56..583e223a10 100644 --- a/src/lib/tcp/tests/tls_listener_unittests.cc +++ b/src/lib/tcp/tests/tls_listener_unittests.cc @@ -76,6 +76,7 @@ public: } test_timer_.cancel(); + io_service_->stop(); io_service_->restart(); try { io_service_->poll(); @@ -167,6 +168,7 @@ public: /// @param timeout Optional value specifying for how long the io service /// should be ran. void runIOService(long timeout = 0) { + io_service_->stop(); io_service_->restart(); if (timeout > 0) { @@ -176,6 +178,7 @@ public: IntervalTimer::ONE_SHOT); } io_service_->run(); + io_service_->stop(); io_service_->restart(); io_service_->poll(); } |