From: Zhansong Gao Date: Wed, 30 Nov 2022 08:01:50 +0000 (+0800) Subject: Make it work even if max_idle_threads is set to 0 X-Git-Tag: fuse-3.13.0~16 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=5aaec929a4e4fe1f3113e4dc6a1469090511207b;p=qemu-gpiodev%2Flibfuse.git 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 --- 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;