]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3281] stop service just in case it was still running
authorRazvan Becheriu <razvan@isc.org>
Wed, 27 Mar 2024 09:44:03 +0000 (11:44 +0200)
committerRazvan Becheriu <razvan@isc.org>
Thu, 4 Apr 2024 05:26:51 +0000 (08:26 +0300)
51 files changed:
src/bin/agent/tests/ca_command_mgr_unittests.cc
src/bin/agent/tests/ca_process_unittests.cc
src/bin/d2/d2_process.cc
src/bin/d2/tests/d2_process_unittests.cc
src/bin/d2/tests/d2_queue_mgr_unittests.cc
src/bin/d2/tests/d2_update_mgr_unittests.cc
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/tests/kea_controller_unittest.cc
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/tests/dhcp6_test_utils.h
src/bin/dhcp6/tests/kea_controller_unittest.cc
src/bin/netconf/http_control_socket.cc
src/bin/netconf/tests/control_socket_unittests.cc
src/bin/netconf/tests/netconf_process_unittests.cc
src/bin/netconf/tests/netconf_unittests.cc
src/hooks/dhcp/high_availability/ha_service.cc
src/hooks/dhcp/high_availability/tests/ha_impl_unittest.cc
src/hooks/dhcp/high_availability/tests/ha_mt_unittest.cc
src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc
src/hooks/dhcp/high_availability/tests/ha_test.cc
src/lib/asiodns/tests/io_fetch_unittest.cc
src/lib/asiolink/tests/interval_timer_unittest.cc
src/lib/asiolink/tests/process_spawn_unittest.cc
src/lib/asiolink/tests/tcp_acceptor_unittest.cc
src/lib/asiolink/tests/tls_acceptor_unittest.cc
src/lib/asiolink/tests/tls_unittest.cc
src/lib/asiolink/tests/unix_domain_socket_unittest.cc
src/lib/config/cmd_http_listener.cc
src/lib/config/tests/client_connection_unittests.cc
src/lib/config/tests/cmd_http_listener_unittests.cc
src/lib/d2srv/tests/dns_client_unittests.cc
src/lib/d2srv/tests/nc_trans_unittests.cc
src/lib/d2srv/testutils/nc_test_utils.cc
src/lib/dhcp_ddns/ncr_io.cc
src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc
src/lib/dhcpsrv/d2_client_mgr.cc
src/lib/dhcpsrv/tests/cfg_expiration_unittest.cc
src/lib/dhcpsrv/tests/cfg_iface_unittest.cc
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/timer_mgr_unittest.cc
src/lib/http/client.cc
src/lib/http/tests/client_mt_unittests.cc
src/lib/http/tests/connection_pool_unittests.cc
src/lib/http/tests/server_client_unittests.cc
src/lib/http/tests/tls_client_unittests.cc
src/lib/http/tests/tls_server_unittests.cc
src/lib/process/d_process.h
src/lib/tcp/mt_tcp_listener_mgr.cc
src/lib/tcp/tests/mt_tcp_listener_mgr_unittests.cc
src/lib/tcp/tests/tcp_listener_unittests.cc
src/lib/tcp/tests/tls_listener_unittests.cc

index 05ec8c7bc77a5f58ee862a8165872981f7b52af6..bd25e58cbfd5915624d32562ab74b46d44b12880 100644 (file)
@@ -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();
 
index e263e594f88df9cd205ba9402e45996e65032972..15b414e4b758473f86b7d7acde933e8222892d52 100644 (file)
@@ -86,6 +86,7 @@ TEST_F(CtrlAgentProcessTest, shutdown) {
                 elapsed.total_milliseconds() <= 400);
 
     timer.cancel();
+    getIOService()->stop();
     getIOService()->restart();
     try {
         getIOService()->poll();
index 40c436d59f7f6671d2c929688a10a901537373a0..134498a4576a9517cec27f971985516b74882e3f 100644 (file)
@@ -440,6 +440,7 @@ D2Process::reconfigureQueueMgr() {
 
 D2Process::~D2Process() {
     queue_mgr_->stopListening();
+    getIOService()->stop();
     getIOService()->restart();
     try {
         getIOService()->poll();
index 35727b814a501dee0550051c252875166398c4bb..83ae4001297cbb05de9bbb327e649e97d670f025 100644 (file)
@@ -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();
index 93f4166f3c65edcea0617f2d210165a3ed20b94f..16d99985673b2a92e220ea637ad9883474b01a8f 100644 (file)
@@ -250,6 +250,7 @@ public:
         sender_->stopSending();
         queue_mgr_->stopListening();
         test_timer_.cancel();
+        io_service_->stop();
         io_service_->restart();
         try {
             io_service_->poll();
index 0360a299c85a2f384a504a5eaf3789c3a9f455b1..71ba0fb277fe00ed8d61354928a16c746b0ff696 100644 (file)
@@ -85,6 +85,7 @@ public:
         if (server_) {
             server_->stop();
         }
+        io_service_->stop();
         io_service_->restart();
         try {
             io_service_->poll();
index 51a9e4735264bf9a2ac88314d9150e4c2e3ef43c..088b4b022203c591550b300ed42301ec5cfd38b5 100644 (file)
@@ -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();
index ab8d62ef72dd0d78bcf1a28b87634675242d70a4..db1fc55a44bd8eed22998b72f398c9f9b804bde4 100644 (file)
@@ -242,6 +242,7 @@ public:
         while (!stopped && (!cond || !cond())) {
             io_service->runOne();
         }
+        io_service->stop();
         io_service->restart();
     }
 
index 86396258603d745a2890b184a57267ed2efe3602..dc0e8c086f39cc1ea179eaec2f5f9cedf4809b63 100644 (file)
@@ -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();
index 57d2894bc303ff2264e28555b5b127533dac2be5..9b13230ddf87384c4c167e1d9238d437aab431b4 100644 (file)
@@ -214,7 +214,7 @@ public:
     virtual ~NakedDhcpv6Srv() {
         // Close the lease database
         isc::dhcp::LeaseMgrFactory::destroy();
-
+        getIOService()->stop();
         getIOService()->restart();
         try {
             getIOService()->poll();
index 7c47f7aee3b9ee324853b5cbde6c9703c6078264..b3afbd4f77c6fb4914765d80a14b1764ed05bb8d 100644 (file)
@@ -227,6 +227,7 @@ public:
         while (!stopped && (!cond || !cond())) {
             io_service->runOne();
         }
+        io_service->stop();
         io_service->restart();
     }
 
index 3e7010f880ea8d1400ce01f100ad7c0bed31a6f9..aa69a5054ec3c5a3ae0c6dc0edb863a23c47b541 100644 (file)
@@ -102,6 +102,7 @@ HttpControlSocket::sendCommand(ConstElementPtr command) {
     io_service->run();
 
     client.stop();
+    io_service->stop();
     io_service->restart();
     try {
         io_service->poll();
index ec038641fe3bf3022c4291e7cf3314d1e702fae6..3dedb20c5607384515cbcc5b6b3efa178b154c72 100644 (file)
@@ -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();
index 436deba4153af468997ce066146458a926b79052..563dc3df501f9bb13d7d848a9916fcdda01d7985 100644 (file)
@@ -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();
index 8bceac0b69de6f260e6deaec055aca4930094778..6b602553f2484bcf257662b8140f144366815a3d 100644 (file)
@@ -130,6 +130,7 @@ public:
         responses_.clear();
         removeUnixSocketFile();
         SysrepoSetup::cleanSharedMemory();
+        io_service_->stop();
         io_service_->restart();
         try {
             io_service_->poll();
index 3ec6d8ca154014eb3976c62e1d997991656f35a0..c295f919313ebd0ed9d7020bb94314fa25f48511 100644 (file)
@@ -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();
index b509ac1e6c88c4f057968efc73529d9f5ebded36..5bda9f456fdf5edb2f313c54f96c47431923ea2a 100644 (file)
@@ -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();
index 36ca35e4393c67db8d4ddd657d92e15559e84bef..89564f370f2b627f6d4c6ea3a9fba96bc94b43eb 100644 (file)
@@ -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();
     }
index e3278814a4cdad433f00e8230e1663037edbf7db..1198f82e6c8e991a45cf9dcbc89a0b4280921ffe 100644 (file)
@@ -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();
index 2e875065ffb11706d5e3e51d7a71e717c3668d92..cd3e9f4371d8adf99bbd7b3b55e3bdf4a82faa39 100644 (file)
@@ -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;
index 4fe94d421b95b4e0b785634f1d412ae496ea645f..66dc67ab5ac260dfd3d88b30fb0913ebedce6084 100644 (file)
@@ -157,6 +157,7 @@ public:
     virtual ~IOFetchTest() {
         shutdown_ = true;
         timer_.cancel();
+        service_->stop();
         service_->restart();
         try {
             service_->poll();
index 214dd4da045714e01f18cfbcbefe6b5b7a905765..c1390519b414ef18765771bd617b085e4e16e4e8 100644 (file)
@@ -29,6 +29,7 @@ protected:
         timer_cancel_success_(false) {
     }
     ~IntervalTimerTest() {
+        io_service_->stop();
         io_service_->restart();
         try {
             io_service_->poll();
index ea7d386bbbe0aeeafd07cc93ee4f08f64d55313f..63355fb8de0569634d10f38b92674fe016a2da2f 100644 (file)
@@ -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();
index 19d39e815bca321e4acc49b301a769e9cfae7807..ebee8a371ed79742b13564bfb6640a8b5dacde25 100644 (file)
@@ -221,6 +221,7 @@ public:
     virtual ~TCPAcceptorTest() {
         running_ = false;
         test_timer_.cancel();
+        io_service_->stop();
         io_service_->restart();
         try {
             io_service_->poll();
index 199c245366bf7103059ca9c8c3e726b18c7a0cd3..aa319619fbbb460a13ce737a9706a2597298f371 100644 (file)
@@ -228,6 +228,7 @@ public:
     virtual ~TLSAcceptorTest() {
         running_ = false;
         test_timer_.cancel();
+        io_service_->stop();
         io_service_->restart();
         try {
             io_service_->poll();
index effbe19b14eb63c83d308f63d4eca534ecb082aa..a045bc59dc0aeec78698406350198ca9b4d442db 100644 (file)
@@ -422,6 +422,7 @@ public:
 
     /// @brief Destructor.
     virtual ~TLSTest() {
+        io_service_->stop();
         io_service_->restart();
         try {
             io_service_->poll();
index 4ed5c127a6114a0219244cd7e2455f882748f9f6..37abacd77a3b900c9b88573b6dda9e4041e53b5a 100644 (file)
@@ -48,6 +48,7 @@ public:
     virtual ~UnixDomainSocketTest() {
         removeUnixSocketFile();
         test_socket_.reset();
+        io_service_->stop();
         io_service_->restart();
         try {
             io_service_->poll();
index ed54552260c9f85dc01ea6faaac93b2b3d6b4684..a516617d0caa563f3bf684847217dfea572e309a 100644 (file)
@@ -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();
index 8684beeb36e73db0a0cc57426876cd8e08cbad42..6e508a6f5c55b5acd2e397bc4a4046ce61d09132 100644 (file)
@@ -46,6 +46,7 @@ public:
         removeUnixSocketFile();
         conn_.reset();
         test_socket_.reset();
+        io_service_->stop();
         io_service_->restart();
         try {
             io_service_->poll();
index a7d34b213a49c277ef793ca66cb516af397af858..8e407583cbc59da13eca31a06570ebc69a3406f9 100644 (file)
@@ -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.
index f00604336293b769eab9c2f4a0265d745848ef77..864acc358798288f61d87e0f3c776f0412f1ccdd 100644 (file)
@@ -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();
index 7c978e520197891a62c278fd9b46fbfd002f775b..2f4a1ba9ce287704508c986ff01e0c870dde7143 100644 (file)
@@ -279,6 +279,7 @@ public:
 
     virtual ~NameChangeTransactionTest() {
         timer_->cancel();
+        io_service_->stop();
         io_service_->restart();
         try {
             io_service_->poll();
index c9b8a671d842eb85ccc29a464c2a587937eec26a..066af32212626648a3106cd878b6853ce9762677 100644 (file)
@@ -227,6 +227,7 @@ TimedIO::TimedIO()
 
 TimedIO::~TimedIO() {
     timer_->cancel();
+    io_service_->stop();
     io_service_->restart();
     try {
         io_service_->poll();
index 70ded4bb8c44849507460fe06470a75aecdd729c..109fa8874ffbafd6a8418ab851d7454bf4681174 100644 (file)
@@ -231,6 +231,7 @@ NameChangeSender::stopSending() {
 
     if (io_service_) {
         try {
+            io_service_->stop();
             io_service_->restart();
             io_service_->poll();
         } catch (const std::exception& ex) {
index b7063ebb814aa2c7399c8275661449fb4b7e9173..904af5b9195043609e352294b56261f9a8ea1695 100644 (file)
@@ -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();
index 022e01212c62044bd5ecf10e30498cf851ae80c5..a1068d42d5bede2f79c941e22e4f590dff02e20f 100644 (file)
@@ -314,6 +314,7 @@ D2ClientMgr::stopSender() {
     }
 
     if (private_io_service_) {
+        private_io_service_->stop();
         private_io_service_->restart();
         try {
             private_io_service_->poll();
index 318d6275d1489bb8506bfbb88e4d168de0555722..d37f0c162008ad461592050ddc90200e7c4b467e 100644 (file)
@@ -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();
     }
 
index 8b9e97d2f4f2c73d6fcb54832507feabf8397c63..1f82e8cca1cadb8346cc7024bf5a9ef5c30068e0 100644 (file)
@@ -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();
 }
 
index 89d6790204020cfaf02e674c722222aa3e5ca3b0..7e2c656017e302985ac641975248d39a1d79d5c1 100644 (file)
@@ -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);
     }
index c991b5577a3172110642d58b9c75a83f91827904..284ca8c199e59ccbeaa546cbfb6e4d95eac05587 100644 (file)
@@ -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();
 }
 
index 7a8f4f57be6a217b30dbd76b61e99cf7278aa210..20ccbc4966d1f9533704ce186a2a5c1fd9754c0f 100644 (file)
@@ -1847,6 +1847,7 @@ public:
         }
 
         if (thread_io_service_) {
+            thread_io_service_->stop();
             thread_io_service_->restart();
             try {
                 thread_io_service_->poll();
index ea15dc0fac8e44716c1e71c24c9a7fe738a4e3a3..7a29ea37c3ab2554e0539c136a03c877da86886e 100644 (file)
@@ -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.
index 810f85035788d9eaf7d76f4b32f4a77d5c81dc20..ac0fac5bda367c2e8cca14b39c9f46fed046e86f 100644 (file)
@@ -114,6 +114,7 @@ public:
 
     /// @brief Destructor.
     ~HttpConnectionPoolTest() {
+        io_service_->stop();
         io_service_->restart();
         try {
             io_service_->poll();
index c9634042811ff45e3683d7fd761f5cb0184a9c3a..62cd2f97179827d021a22fc27741083da8a2b001 100644 (file)
@@ -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();
index 03d57ef0f448aa0ebee7a81e860fb52a3ef83508..dcba531ee46d569f9ac9098390a50ab1a16fa179 100644 (file)
@@ -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();
     }
index cca66ac8f145c5d05386356531f3f7361fe7a90b..7d98a81e45a9ba84dc3a0967e04e0c5dc259d503 100644 (file)
@@ -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();
     }
index f7bee855aec327a872ad9f68a9234ad3dc34b722..8926379db235769b03920fbf84650b58e006f304 100644 (file)
@@ -146,6 +146,7 @@ public:
 
     /// @brief Destructor
     virtual ~DProcessBase() {
+        io_service_->stop();
         io_service_->restart();
         try {
             io_service_->poll();
index cacc34285a661ab8f8534dc0f675932ff2e381d4..5b71d622d1b971dc18ce2071d5fc89840a197cda 100644 (file)
@@ -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();
index 80be0617085f390290e95bf1e89ebe3598ae0638..58c394afe707def887cdd3577d18484b3d3f1a1a 100644 (file)
@@ -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.
index e9deff3e8dcb8444a971ce969130771fb70cf5d9..5396c8f8a4d0abb1c865ad6497cd7e7ee65864a2 100644 (file)
@@ -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();
     }
index c4d1fadf56174d1c00fc2213ff06e876c5f4621d..583e223a1071d9d6fa720f1c5410a070f0930f3f 100644 (file)
@@ -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();
     }