diff options
author | Amar Tumballi <amarts@redhat.com> | 2012-08-07 10:03:47 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-08-06 21:51:35 -0700 |
commit | 828b2b7059093972381bc64047025a7d8cac508e (patch) | |
tree | 3be94074784fa237436723db79e3c3144e59dcd4 | |
parent | 87d453f7211d3a38113aea895947143ea8bf7d68 (diff) |
core: moved back the pthread_key_t specific variables as global
in a patch to move all the global variables inside 'ctx', moved all
the pthread_key_t specific globals, which needed to be global, not inside
some structures.
Change-Id: I5e7107a8a64f5b80e90fd469fb084f62b2312705
Signed-off-by: Amar Tumballi <amarts@redhat.com>
BUG: 764890
Reviewed-on: http://review.gluster.com/3783
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r-- | libglusterfs/src/globals.c | 48 | ||||
-rw-r--r-- | libglusterfs/src/globals.h | 6 | ||||
-rw-r--r-- | libglusterfs/src/glusterfs.h | 6 | ||||
-rw-r--r-- | libglusterfs/src/syncop.c | 2 |
4 files changed, 31 insertions, 31 deletions
diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c index d84e49dcc3d..05ff52c2c52 100644 --- a/libglusterfs/src/globals.c +++ b/libglusterfs/src/globals.c @@ -72,6 +72,12 @@ const char *gf_fop_list[GF_FOP_MAXVALUE] = { xlator_t global_xlator; static pthread_key_t this_xlator_key; +static pthread_key_t synctask_key; +static pthread_key_t uuid_buf_key; +static char global_uuid_buf[GF_UUID_BUF_SIZE]; +static pthread_key_t lkowner_buf_key; +static char global_lkowner_buf[GF_LKOWNER_BUF_SIZE]; + void glusterfs_this_destroy (void *ptr) @@ -161,33 +167,33 @@ glusterfs_this_set (xlator_t *this) /* SYNCTASK */ int -synctask_init (glusterfs_ctx_t *ctx) +synctask_init () { int ret = 0; - ret = pthread_key_create (&ctx->synctask_key, NULL); + ret = pthread_key_create (&synctask_key, NULL); return ret; } void * -synctask_get (glusterfs_ctx_t *ctx) +synctask_get () { void *synctask = NULL; - synctask = pthread_getspecific (ctx->synctask_key); + synctask = pthread_getspecific (synctask_key); return synctask; } int -synctask_set (glusterfs_ctx_t *ctx, void *synctask) +synctask_set (void *synctask) { int ret = 0; - pthread_setspecific (ctx->synctask_key, synctask); + pthread_setspecific (synctask_key, synctask); return ret; } @@ -201,27 +207,27 @@ glusterfs_uuid_buf_destroy (void *ptr) } int -glusterfs_uuid_buf_init (glusterfs_ctx_t *ctx) +glusterfs_uuid_buf_init () { int ret = 0; - ret = pthread_key_create (&ctx->uuid_buf_key, + ret = pthread_key_create (&uuid_buf_key, glusterfs_uuid_buf_destroy); return ret; } char * -glusterfs_uuid_buf_get (glusterfs_ctx_t *ctx) +glusterfs_uuid_buf_get () { char *buf; int ret = 0; - buf = pthread_getspecific (ctx->uuid_buf_key); + buf = pthread_getspecific (uuid_buf_key); if(!buf) { buf = MALLOC (GF_UUID_BUF_SIZE); - ret = pthread_setspecific (ctx->uuid_buf_key, (void *) buf); + ret = pthread_setspecific (uuid_buf_key, (void *) buf); if (ret) - buf = ctx->uuid_buf; + buf = global_uuid_buf; } return buf; } @@ -235,27 +241,27 @@ glusterfs_lkowner_buf_destroy (void *ptr) } int -glusterfs_lkowner_buf_init (glusterfs_ctx_t *ctx) +glusterfs_lkowner_buf_init () { int ret = 0; - ret = pthread_key_create (&ctx->lkowner_buf_key, + ret = pthread_key_create (&lkowner_buf_key, glusterfs_lkowner_buf_destroy); return ret; } char * -glusterfs_lkowner_buf_get (glusterfs_ctx_t *ctx) +glusterfs_lkowner_buf_get () { char *buf; int ret = 0; - buf = pthread_getspecific (ctx->lkowner_buf_key); + buf = pthread_getspecific (lkowner_buf_key); if(!buf) { buf = MALLOC (GF_LKOWNER_BUF_SIZE); - ret = pthread_setspecific (ctx->lkowner_buf_key, (void *) buf); + ret = pthread_setspecific (lkowner_buf_key, (void *) buf); if (ret) - buf = ctx->lkowner_buf; + buf = global_lkowner_buf; } return buf; } @@ -274,21 +280,21 @@ glusterfs_globals_init (glusterfs_ctx_t *ctx) goto out; } - ret = glusterfs_uuid_buf_init (ctx); + ret = glusterfs_uuid_buf_init (); if(ret) { gf_log ("", GF_LOG_CRITICAL, "ERROR: glusterfs uuid buffer init failed"); goto out; } - ret = glusterfs_lkowner_buf_init (ctx); + ret = glusterfs_lkowner_buf_init (); if(ret) { gf_log ("", GF_LOG_CRITICAL, "ERROR: glusterfs lkowner buffer init failed"); goto out; } - ret = synctask_init (ctx); + ret = synctask_init (); if (ret) { gf_log ("", GF_LOG_CRITICAL, "ERROR: glusterfs synctask init failed"); diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h index 47a81afb808..e13902b2992 100644 --- a/libglusterfs/src/globals.h +++ b/libglusterfs/src/globals.h @@ -24,12 +24,12 @@ int glusterfs_this_set (xlator_t *); /* task */ void *synctask_get (); -int synctask_set (glusterfs_ctx_t *, void *); +int synctask_set (void *); /* uuid_buf */ -char *glusterfs_uuid_buf_get(glusterfs_ctx_t *); +char *glusterfs_uuid_buf_get(); /* lkowner_buf */ -char *glusterfs_lkowner_buf_get(glusterfs_ctx_t *); +char *glusterfs_lkowner_buf_get(); /* init */ int glusterfs_globals_init (glusterfs_ctx_t *ctx); diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 70a50af6a5b..5c2843851fe 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -383,12 +383,6 @@ struct _glusterfs_ctx { call to fsd-mgmt */ gf_log_handle_t log; /* all logging related variables */ - pthread_key_t synctask_key; - pthread_key_t uuid_buf_key; - char uuid_buf[GF_UUID_BUF_SIZE]; - pthread_key_t lkowner_buf_key; - char lkowner_buf[GF_LKOWNER_BUF_SIZE]; - int mem_acct_enable; }; diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index 95d6087f44c..7b34c631d8c 100644 --- a/libglusterfs/src/syncop.c +++ b/libglusterfs/src/syncop.c @@ -284,7 +284,7 @@ synctask_switchto (struct synctask *task) env = task->env; - synctask_set (THIS->ctx, task); + synctask_set (task); THIS = task->xl; task->woken = 0; |