Correctly stop "own thread" in service destructor.
This change fixes the scheduler and win_iocp_io_context destructors so that they correctly stop the internal thread that was created in the constructor. This fixes a deadlock that can occur when two threads concurrently attempt to create the first I/O object associated with a non-native I/O execution context.
This commit is contained in:
parent
71324d7cbb
commit
50e2c8c88e
@ -135,6 +135,10 @@ scheduler::~scheduler()
|
||||
{
|
||||
if (thread_)
|
||||
{
|
||||
mutex::scoped_lock lock(mutex_);
|
||||
shutdown_ = true;
|
||||
stop_all_threads(lock);
|
||||
lock.unlock();
|
||||
thread_->join();
|
||||
delete thread_;
|
||||
}
|
||||
|
@ -113,6 +113,7 @@ win_iocp_io_context::~win_iocp_io_context()
|
||||
{
|
||||
if (thread_.get())
|
||||
{
|
||||
stop();
|
||||
thread_->join();
|
||||
thread_.reset();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user