mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
Fix thread pool shutdown race
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
462020d19a
commit
d1bcde3753
1 changed files with 4 additions and 3 deletions
|
|
@ -686,12 +686,13 @@ inline
|
|||
void
|
||||
ThreadPool::_remove_self(pthread_t t_)
|
||||
{
|
||||
// During shutdown the destructor owns all joins; don't detach.
|
||||
mutex_lockguard(_threads_mutex);
|
||||
|
||||
// Check _stop under the lock so the destructor can't snapshot this
|
||||
// thread for joining and then race with us detaching ourselves.
|
||||
if(_stop.load(std::memory_order_acquire))
|
||||
return;
|
||||
|
||||
mutex_lockguard(_threads_mutex);
|
||||
|
||||
auto it = std::find(_threads.begin(),_threads.end(),t_);
|
||||
if(it != _threads.end())
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue