diff --git a/lib/fuse.c b/../fuse.c index d1d873a..c3ddf68 100644 --- a/lib/fuse.c +++ b/../fuse.c @@ -38,6 +38,7 @@ #include #include #include +#include #define FUSE_NODE_SLAB 1 @@ -153,6 +154,7 @@ struct fuse { struct list_head partial_slabs; struct list_head full_slabs; pthread_t prune_thread; + atomic_flag cancel; }; struct lock { @@ -4637,9 +4639,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; @@ -4657,7 +4662,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); }