--- a/lib/fuse.c +++ b/lib/fuse.c @@ -39,6 +39,7 @@ #include #include #include +#include #define FUSE_NODE_SLAB 1 @@ -128,6 +129,7 @@ struct fuse { struct list_head partial_slabs; struct list_head full_slabs; pthread_t prune_thread; + atomic_flag cancel; }; struct lock { @@ -4843,9 +4845,12 @@ static void *fuse_prune_nodes(void *fuse) { struct fuse *f = fuse; int sleep_time; + atomic_flag_clear(&f->cancel); while(1) { sleep_time = fuse_clean_cache(f); + if (atomic_flag_test_and_set(&f->cancel)) pthread_exit(NULL); + atomic_flag_clear(&f->cancel); sleep(sleep_time); } return NULL; @@ -4863,7 +4868,7 @@ void fuse_stop_cleanup_thread(struct fuse *f) { if (lru_enabled(f)) { pthread_mutex_lock(&f->lock); - pthread_cancel(f->prune_thread); + atomic_flag_test_and_set(&f->cancel); pthread_mutex_unlock(&f->lock); pthread_join(f->prune_thread, NULL); }