aboutsummaryrefslogtreecommitdiff
path: root/lib/fuse_loop_mt.c
diff options
context:
space:
mode:
authorGravatar Miklos Szeredi <miklos@szeredi.hu>2005-11-29 20:07:23 +0000
committerGravatar Miklos Szeredi <miklos@szeredi.hu>2005-11-29 20:07:23 +0000
commit40d7b38b29cb251e84b3619b8040ac248d944e84 (patch)
treee9a638f30eb1b59373fe2fb9c0283fff0cc8cbff /lib/fuse_loop_mt.c
parentfb02fec03ed37ba1e249eb22bbcb8591f538e184 (diff)
fix
Diffstat (limited to 'lib/fuse_loop_mt.c')
-rw-r--r--lib/fuse_loop_mt.c8
1 files changed, 5 insertions, 3 deletions
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);