mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-21 03:55:11 +00:00
Fix thread pool shutdown race
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot
parent
462020d19a
commit
d1bcde3753
@@ -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())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user