diff --git a/boost/network/protocol/http/client/async_impl.hpp b/boost/network/protocol/http/client/async_impl.hpp index 18f0e64ba..31578c2eb 100644 --- a/boost/network/protocol/http/client/async_impl.hpp +++ b/boost/network/protocol/http/client/async_impl.hpp @@ -74,7 +74,9 @@ struct async_client void wait_complete() { sentinel_.reset(); if (lifetime_thread_.get()) { - lifetime_thread_->join(); + if (lifetime_thread_->joinable() && lifetime_thread_->get_id() != std::this_thread::get_id()) { + lifetime_thread_->join(); + } lifetime_thread_.reset(); } } diff --git a/boost/network/utils/thread_group.hpp b/boost/network/utils/thread_group.hpp index 0540b6afb..d9b14439c 100644 --- a/boost/network/utils/thread_group.hpp +++ b/boost/network/utils/thread_group.hpp @@ -55,7 +55,7 @@ class thread_group { std::unique_lock guard(m); for (auto &thread : threads) { - if (thread->joinable()) { + if (thread->joinable() && thread->get_id() != std::this_thread::get_id()) { thread->join(); } }