diff --git a/vendored/libfuse/include/thread_pool.hpp b/vendored/libfuse/include/thread_pool.hpp index 00c915aa..8b9ba024 100644 --- a/vendored/libfuse/include/thread_pool.hpp +++ b/vendored/libfuse/include/thread_pool.hpp @@ -24,7 +24,6 @@ #include "mutex.hpp" #include -#include #include #include #include @@ -1042,8 +1041,12 @@ ThreadPool::enqueue_work_autoscale(ThreadPool::PToken &ptok_, return; } - assert(static_cast(f) && - "BoundedQueue::try_enqueue moved the callable despite returning false"); + // If try_enqueue moved the callable despite returning false, the + // Func is empty and would act as a poison pill — re-enqueuing it + // could cause a worker to exit. Throw so the caller notices + // immediately rather than silently corrupting the pool. + if(!static_cast(f)) + throw std::logic_error("BoundedQueue::try_enqueue moved the callable despite returning false"); _maybe_grow_on_pressure(); @@ -1067,8 +1070,8 @@ ThreadPool::enqueue_work_autoscale(FuncType &&func_) return; } - assert(static_cast(f) && - "BoundedQueue::try_enqueue moved the callable despite returning false"); + if(!static_cast(f)) + throw std::logic_error("BoundedQueue::try_enqueue moved the callable despite returning false"); _maybe_grow_on_pressure();