From 01971e2770f91374f85b8b066179d9a05ebf2a44 Mon Sep 17 00:00:00 2001 From: Oleg Abrosimov Date: Tue, 13 Feb 2018 13:27:23 +0700 Subject: [PATCH 1/2] fix Resource deadlock avoided error --- boost/network/protocol/http/client/async_impl.hpp | 4 +++- boost/network/utils/thread_group.hpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/boost/network/protocol/http/client/async_impl.hpp b/boost/network/protocol/http/client/async_impl.hpp index 18f0e64ba..b1f1c839c 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() != boost::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..91d8f591a 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() != boost::this_thread::get_id()) { thread->join(); } } From 39823ba25d4fde5af1fdb09c2de97ca5de7f8ea9 Mon Sep 17 00:00:00 2001 From: Oleg Abrosimov Date: Tue, 13 Feb 2018 13:46:52 +0700 Subject: [PATCH 2/2] fix boost -> std --- boost/network/protocol/http/client/async_impl.hpp | 2 +- boost/network/utils/thread_group.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/boost/network/protocol/http/client/async_impl.hpp b/boost/network/protocol/http/client/async_impl.hpp index b1f1c839c..31578c2eb 100644 --- a/boost/network/protocol/http/client/async_impl.hpp +++ b/boost/network/protocol/http/client/async_impl.hpp @@ -74,7 +74,7 @@ struct async_client void wait_complete() { sentinel_.reset(); if (lifetime_thread_.get()) { - if (lifetime_thread_->joinable() && lifetime_thread_->get_id() != boost::this_thread::get_id()) { + 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 91d8f591a..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() && thread->get_id() != boost::this_thread::get_id()) { + if (thread->joinable() && thread->get_id() != std::this_thread::get_id()) { thread->join(); } }