47 lines
1.2 KiB
Diff
47 lines
1.2 KiB
Diff
--- a/lib/fuse_loop_mt.c
|
|
+++ b/lib/fuse_loop_mt.c
|
|
@@ -25,6 +25,7 @@
|
|
#include <sys/ioctl.h>
|
|
#include <assert.h>
|
|
#include <limits.h>
|
|
+#include <stdatomic.h>
|
|
|
|
/* Environment var controlling the thread stack size */
|
|
#define ENVNAME_THREAD_STACK "FUSE_THREAD_STACK"
|
|
@@ -45,6 +46,7 @@ struct fuse_worker {
|
|
struct fuse_buf fbuf;
|
|
struct fuse_chan *ch;
|
|
struct fuse_mt *mt;
|
|
+ atomic_flag cancel;
|
|
};
|
|
|
|
struct fuse_mt {
|
|
@@ -130,9 +132,8 @@ static void *fuse_do_work(void *data)
|
|
int isforget = 0;
|
|
int res;
|
|
|
|
- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
|
|
+ if (!atomic_flag_test_and_set(&w->cancel)) pthread_exit(NULL);
|
|
res = fuse_session_receive_buf_int(mt->se, &w->fbuf, w->ch);
|
|
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
|
|
if (res == -EINTR)
|
|
continue;
|
|
if (res <= 0) {
|
|
@@ -297,6 +298,7 @@ static int fuse_loop_start_thread(struct
|
|
}
|
|
}
|
|
|
|
+ atomic_flag_test_and_set(&w->cancel);
|
|
res = fuse_start_thread(&w->thread_id, fuse_do_work, w);
|
|
if (res == -1) {
|
|
fuse_chan_put(w->ch);
|
|
@@ -364,7 +366,7 @@ int err;
|
|
|
|
pthread_mutex_lock(&mt.lock);
|
|
for (w = mt.main.next; w != &mt.main; w = w->next)
|
|
- pthread_cancel(w->thread_id);
|
|
+ atomic_flag_clear(&w->cancel);
|
|
mt.exit = 1;
|
|
pthread_mutex_unlock(&mt.lock);
|
|
|