Get rid of MULTITHREADED_REFUSE for context queries. We can simply
use the pthread codepaths always.
This commit is contained in:
parent
07d197d99e
commit
c683f6f6b5
@ -1,9 +1,10 @@
|
||||
# $NetBSD: Makefile,v 1.6 2007/07/18 22:38:59 pooka Exp $
|
||||
# $NetBSD: Makefile,v 1.7 2007/10/21 16:46:52 pooka Exp $
|
||||
|
||||
USE_FORT?= yes # data driven bugs?
|
||||
|
||||
LIB= refuse
|
||||
LIBDPLIBS+= puffs ${.CURDIR}/../libpuffs
|
||||
LIBDPLIBS+= puffs ${.CURDIR}/../libpuffs \
|
||||
pthread ${.CURDIR}/../libpthread
|
||||
|
||||
.ifdef DEBUG
|
||||
FUSE_OPT_DEBUG_FLAGS= -g -DFUSE_OPT_DEBUG
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: refuse.c,v 1.76 2007/10/21 14:36:35 pooka Exp $ */
|
||||
/* $NetBSD: refuse.c,v 1.77 2007/10/21 16:46:52 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright © 2007 Alistair Crooks. All rights reserved.
|
||||
@ -30,7 +30,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(lint)
|
||||
__RCSID("$NetBSD: refuse.c,v 1.76 2007/10/21 14:36:35 pooka Exp $");
|
||||
__RCSID("$NetBSD: refuse.c,v 1.77 2007/10/21 16:46:52 pooka Exp $");
|
||||
#endif /* !lint */
|
||||
|
||||
#include <assert.h>
|
||||
@ -38,10 +38,8 @@ __RCSID("$NetBSD: refuse.c,v 1.76 2007/10/21 14:36:35 pooka Exp $");
|
||||
#include <errno.h>
|
||||
#include <fuse.h>
|
||||
#include <paths.h>
|
||||
#include <unistd.h>
|
||||
#ifdef MULTITHREADED_REFUSE
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
@ -151,17 +149,14 @@ static ino_t fakeino = 3;
|
||||
* we follow fuse's lead and use the pthread specific information to hold
|
||||
* a reference to the fuse_context structure for this thread.
|
||||
*/
|
||||
#ifdef MULTITHREADED_REFUSE
|
||||
static pthread_mutex_t context_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_key_t context_key;
|
||||
static uint64_t context_refc;
|
||||
#endif
|
||||
|
||||
/* return the fuse_context struct related to this thread */
|
||||
struct fuse_context *
|
||||
fuse_get_context(void)
|
||||
{
|
||||
#ifdef MULTITHREADED_REFUSE
|
||||
struct fuse_context *ctxt;
|
||||
|
||||
if ((ctxt = pthread_getspecific(context_key)) == NULL) {
|
||||
@ -171,27 +166,19 @@ fuse_get_context(void)
|
||||
pthread_setspecific(context_key, ctxt);
|
||||
}
|
||||
return ctxt;
|
||||
#else
|
||||
static struct fuse_context fcon;
|
||||
|
||||
return &fcon;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* used as a callback function */
|
||||
#ifdef MULTITHREADED_REFUSE
|
||||
static void
|
||||
free_context(void *ctxt)
|
||||
{
|
||||
free(ctxt);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* make the pthread key */
|
||||
static int
|
||||
create_context_key(void)
|
||||
{
|
||||
#ifdef MULTITHREADED_REFUSE
|
||||
if (pthread_mutex_lock(&context_mutex) == 0) {
|
||||
/* we have the lock, attempt to create the key */
|
||||
if (pthread_key_create(&context_key, free_context) != 0) {
|
||||
@ -203,23 +190,18 @@ create_context_key(void)
|
||||
context_refc += 1;
|
||||
pthread_mutex_unlock(&context_mutex);
|
||||
return 1;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* delete the pthread key */
|
||||
static void
|
||||
delete_context_key(void)
|
||||
{
|
||||
#ifdef MULTITHREADED_REFUSE
|
||||
pthread_mutex_lock(&context_mutex);
|
||||
if (--context_refc == 0) {
|
||||
free(pthread_getspecific(context_key));
|
||||
pthread_key_delete(context_key);
|
||||
}
|
||||
pthread_mutex_unlock(&context_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* set the uid and gid of the calling process in the current fuse context */
|
||||
|
Loading…
Reference in New Issue
Block a user