diff --git a/src/kernel/Communicator.cc b/src/kernel/Communicator.cc index c76d7bcfc5..13d988f1bb 100644 --- a/src/kernel/Communicator.cc +++ b/src/kernel/Communicator.cc @@ -1242,19 +1242,12 @@ void Communicator::handler_thread_routine(void *context) break; default: free(res); - if (comm->thrdpool) - thrdpool_exit(comm->thrdpool); - continue; + thrdpool_exit(comm->thrdpool); + return; } free(res); } - - if (!comm->thrdpool) - { - mpoller_destroy(comm->mpoller); - msgqueue_destroy(comm->msgqueue); - } } int Communicator::append_message(const void *buf, size_t *size, @@ -1608,15 +1601,12 @@ int Communicator::init(size_t poller_threads, size_t handler_threads) void Communicator::deinit() { - int in_handler = this->is_handler_thread(); - this->stop_flag = 1; mpoller_stop(this->mpoller); msgqueue_set_nonblock(this->msgqueue); thrdpool_destroy(NULL, this->thrdpool); - this->thrdpool = NULL; - if (!in_handler) - Communicator::handler_thread_routine(this); + mpoller_destroy(this->mpoller); + msgqueue_destroy(this->msgqueue); } int Communicator::nonblock_connect(CommTarget *target)