From 40d7b38b29cb251e84b3619b8040ac248d944e84 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Tue, 29 Nov 2005 20:07:23 +0000 Subject: [PATCH] fix --- ChangeLog | 4 ++++ lib/fuse_loop_mt.c | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 50bd2db..ca86052 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,10 @@ * Check if '-msoft-float' option is supported by compiler when configuring for a 2.4.x kernel. Bug report by Mark Haney + * In multithreaded loop send a TERM signal to the main thread if + one of the other threads exit. Needed on FreeBSD for a clean exit + on umount. Should not cause any harm on Linux either + 2005-11-28 Miklos Szeredi * Fix bug in 32-bit file handle compatibility diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c index 0532230..37f0922 100644 --- a/lib/fuse_loop_mt.c +++ b/lib/fuse_loop_mt.c @@ -27,6 +27,7 @@ struct fuse_worker { struct fuse_chan *ch; struct fuse_chan *prevch; pthread_t threads[FUSE_MAX_WORKERS]; + pthread_t main_thread; int exit; int error; }; @@ -59,7 +60,6 @@ static int start_thread(struct fuse_worker *w, pthread_t *thread_id); static void *do_work(void *data) { struct fuse_worker *w = (struct fuse_worker *) data; - int is_mainthread = (w->numworker == 1); size_t bufsize = fuse_chan_bufsize(w->prevch); char *buf = (char *) malloc(bufsize); if (!buf) { @@ -107,9 +107,10 @@ static void *do_work(void *data) } pthread_cleanup_pop(1); - /* Wait for cancellation */ - if (!is_mainthread) + if (pthread_self() != w->main_thread) { + pthread_kill(w->main_thread, SIGTERM); pause(); + } return NULL; } @@ -162,6 +163,7 @@ int fuse_session_loop_mt(struct fuse_session *se) w->error = 0; w->numworker = 1; w->numavail = 1; + w->main_thread = pthread_self(); mutex_init(&w->lock); do_work(w); -- 2.30.2