diff options
Diffstat (limited to 'lib/fuse_mt.c')
-rw-r--r-- | lib/fuse_mt.c | 73 |
1 files changed, 1 insertions, 72 deletions
diff --git a/lib/fuse_mt.c b/lib/fuse_mt.c index b0b31dd..ee8ef40 100644 --- a/lib/fuse_mt.c +++ b/lib/fuse_mt.c @@ -15,61 +15,6 @@ #include <pthread.h> #include <assert.h> -static pthread_key_t context_key; -static pthread_mutex_t context_lock = PTHREAD_MUTEX_INITIALIZER; -static int context_ref; - -static struct fuse_context *mt_getcontext(void) -{ - struct fuse_context *ctx; - - ctx = (struct fuse_context *) pthread_getspecific(context_key); - if (ctx == NULL) { - ctx = (struct fuse_context *) malloc(sizeof(struct fuse_context)); - if (ctx == NULL) { - fprintf(stderr, "fuse: failed to allocate thread specific data\n"); - return NULL; - } - pthread_setspecific(context_key, ctx); - } - return ctx; -} - -static void mt_freecontext(void *data) -{ - free(data); -} - -static int mt_create_context_key(void) -{ - int err = 0; - pthread_mutex_lock(&context_lock); - if (!context_ref) { - err = pthread_key_create(&context_key, mt_freecontext); - if (err) - fprintf(stderr, "fuse: failed to create thread specific key: %s\n", - strerror(err)); - else - fuse_set_getcontext_func(mt_getcontext); - } - if (!err) - context_ref ++; - pthread_mutex_unlock(&context_lock); - return err; -} - -static void mt_delete_context_key(void) -{ - pthread_mutex_lock(&context_lock); - context_ref--; - if (!context_ref) { - fuse_set_getcontext_func(NULL); - free(pthread_getspecific(context_key)); - pthread_key_delete(context_key); - } - pthread_mutex_unlock(&context_lock); -} - struct procdata { struct fuse *f; struct fuse_chan *prevch; @@ -162,33 +107,17 @@ int fuse_loop_mt_proc(struct fuse *f, fuse_processor_t proc, void *data) return -1; } fuse_session_add_chan(se, ch); - - if (mt_create_context_key() != 0) { - fuse_session_destroy(se); - return -1; - } - res = fuse_session_loop_mt(se); - - mt_delete_context_key(); fuse_session_destroy(se); return res; } int fuse_loop_mt(struct fuse *f) { - int res; - if (f == NULL) return -1; - if (mt_create_context_key() != 0) - return -1; - - res = fuse_session_loop_mt(fuse_get_session(f)); - - mt_delete_context_key(); - return res; + return fuse_session_loop_mt(fuse_get_session(f)); } __asm__(".symver fuse_loop_mt_proc,__fuse_loop_mt@"); |