+2005-11-21 Miklos Szeredi <miklos@szeredi.hu>
+
+ * Don't use async cancelation in multithreaded loop. This makes
+ it more portable to systems where read() is not async cancel safe.
+ Report from Andriy Gapon
+
2005-11-20 Miklos Szeredi <miklos@szeredi.hu>
* Warn if API version 11 compatibility is requested
struct fuse_chan *ch;
struct fuse_chan *prevch;
pthread_t threads[FUSE_MAX_WORKERS];
+ int exit;
int error;
};
pthread_cleanup_push(free, buf);
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
- pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+ pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
while (!fuse_session_exited(w->se)) {
int res = fuse_chan_receive(w->prevch, buf, bufsize);
}
pthread_mutex_lock(&w->lock);
+ if (w->exit) {
+ pthread_mutex_unlock(&w->lock);
+ break;
+ }
w->numavail--;
if (w->numavail == 0 && w->numworker < FUSE_MAX_WORKERS) {
if (w->numworker < FUSE_MAX_WORKERS) {
return -1;
}
- pthread_detach(*thread_id);
return 0;
}
pthread_mutex_lock(&w->lock);
for (i = 1; i < w->numworker; i++)
pthread_cancel(w->threads[i]);
+ w->exit = 1;
pthread_mutex_unlock(&w->lock);
+ for (i = 1; i < w->numworker; i++)
+ pthread_join(w->threads[i], NULL);
pthread_mutex_destroy(&w->lock);
err = w->error;
fuse_chan_destroy(w->ch);