From aff4ea1f011a6d7aa0fb62294f91bd9954efd641 Mon Sep 17 00:00:00 2001 From: "Antonio S. Musumeci" Date: Fri, 10 Apr 2026 21:32:14 -0400 Subject: [PATCH] checkpoint --- vendored/libfuse/include/thread_pool.hpp | 25 ++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/vendored/libfuse/include/thread_pool.hpp b/vendored/libfuse/include/thread_pool.hpp index 42b09ae3..f785af4c 100644 --- a/vendored/libfuse/include/thread_pool.hpp +++ b/vendored/libfuse/include/thread_pool.hpp @@ -321,7 +321,12 @@ ThreadPool::ThreadPool(const unsigned thread_count_, else { _monitor_started = true; - pthread_setname_np(_monitor_thread, "tp.monitor"); + { + std::string mon_name = _name.empty() ? "tp.monitor" : (_name + ".mon"); + if(mon_name.size() > 15) + mon_name.resize(15); + pthread_setname_np(_monitor_thread, mon_name.c_str()); + } syslog(LOG_DEBUG, "threadpool (%s): auto-scaling enabled [%zu, %zu]", _name.c_str(), @@ -347,9 +352,6 @@ ThreadPool::~ThreadPool() pthread_join(_monitor_thread,NULL); } - pthread_cond_destroy(&_monitor_cond); - pthread_mutex_destroy(&_monitor_mutex); - // Snapshot threads under lock to close the race with _remove_self. // After _stop is set, _remove_self becomes a no-op, so no thread // will detach or erase itself from this point forward. @@ -364,19 +366,17 @@ ThreadPool::~ThreadPool() _name.c_str(), snapshot.size()); - // Drain any pending _remove_count so workers exiting via poison - // pills don't also try to detach themselves (which would be a - // no-op due to _stop, but avoids confusion in debugging). - // Use release ordering so the store is visible to workers before - // they dequeue the poison pills enqueued below. - _remove_count.store(0,std::memory_order_release); - // Enqueue one poison pill per thread for(std::size_t i = 0; i < snapshot.size(); ++i) _queue.enqueue_unbounded(Func{}); for(auto t : snapshot) pthread_join(t,NULL); + + // Destroy the monitor condvar/mutex only after all workers are + // joined, so no thread can still reference them. + pthread_cond_destroy(&_monitor_cond); + pthread_mutex_destroy(&_monitor_mutex); } @@ -481,11 +481,12 @@ ThreadPool::start_routine_autoscale(void *arg_) ThreadPool::Queue &q = btp->_queue; ThreadPool::CToken ctok(btp->_queue.make_ctoken()); std::string const name = btp->_name; + std::int64_t const idle_threshold = btp->_scaling_config.idle_threshold_usecs; while(true) { bool got = q.try_wait_dequeue_for(ctok,func, - btp->_scaling_config.idle_threshold_usecs); + idle_threshold); if(!got) {