From 5aaec929a4e4fe1f3113e4dc6a1469090511207b Mon Sep 17 00:00:00 2001 From: Zhansong Gao Date: Wed, 30 Nov 2022 16:01:50 +0800 Subject: Make it work even if max_idle_threads is set to 0 It may happen that none of the worker threads are running if max_idle_threads is set to 0 although few people will do this. Adding a limit of keeping at least one worker thread will make our code more rigorous. Signed-off-by: Zhansong Gao --- lib/fuse_loop_mt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c index 6002e19..72c74a8 100644 --- a/lib/fuse_loop_mt.c +++ b/lib/fuse_loop_mt.c @@ -179,7 +179,7 @@ static void *fuse_do_work(void *data) * is indeed a good reason to destruct threads it should be done * delayed, a moving average might be useful for that. */ - if (mt->max_idle != -1 && mt->numavail > mt->max_idle) { + if (mt->max_idle != -1 && mt->numavail > mt->max_idle && mt->numworker > 1) { if (mt->exit) { pthread_mutex_unlock(&mt->lock); return NULL; -- cgit v1.2.1