From f5daa99031b51eae83a0e91c3a0e86929dc0075b Mon Sep 17 00:00:00 2001 From: zhaoliwei Date: Fri, 6 Dec 2019 10:19:23 +0800 Subject: [PATCH 1/2] fix the bug in shared_io_service --- src/core/tools/common/shared_io_service.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/tools/common/shared_io_service.h b/src/core/tools/common/shared_io_service.h index 9b0b873f57..c533fee147 100644 --- a/src/core/tools/common/shared_io_service.h +++ b/src/core/tools/common/shared_io_service.h @@ -66,6 +66,14 @@ class shared_io_service : public utils::singleton } } + ~shared_io_service() + { + ios.stop(); + for (int i = 0; i < _io_service_worker_count; i++) { + _workers[i]->join(); + } + } + boost::asio::io_service ios; private: From daa54e4b4511b5ac24bb0096f2225cd1a5e9a723 Mon Sep 17 00:00:00 2001 From: zhaoliwei Date: Fri, 6 Dec 2019 11:11:43 +0800 Subject: [PATCH 2/2] fix --- src/core/tools/common/shared_io_service.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/tools/common/shared_io_service.h b/src/core/tools/common/shared_io_service.h index c533fee147..8438498ec5 100644 --- a/src/core/tools/common/shared_io_service.h +++ b/src/core/tools/common/shared_io_service.h @@ -69,8 +69,8 @@ class shared_io_service : public utils::singleton ~shared_io_service() { ios.stop(); - for (int i = 0; i < _io_service_worker_count; i++) { - _workers[i]->join(); + for (auto worker : _workers) { + worker->join(); } }