diff options
author | Vikas Gorur <vikas@gluster.com> | 2009-06-09 05:08:59 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-06-11 07:51:27 -0700 |
commit | e7e6144a7688b35255ef5d69b060bd90e319679f (patch) | |
tree | 903b1a062916088a55e8d820a6131a9f8758d941 /libglusterfs/src/globals.c | |
parent | f7ca417394aeb5a8c2144e3b2ae6493ef172b32d (diff) |
Functions to store a central log flag in TLS.
The flag is set in TLS so that a re-entry into
gf_central_log does not deadlock.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
Diffstat (limited to 'libglusterfs/src/globals.c')
-rw-r--r-- | libglusterfs/src/globals.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c index 38727a25afe..ae7fdcd616a 100644 --- a/libglusterfs/src/globals.c +++ b/libglusterfs/src/globals.c @@ -149,6 +149,61 @@ glusterfs_this_set (xlator_t *this) } +/* IS_CENTRAL_LOG */ + +static pthread_key_t central_log_flag_key; + +void +glusterfs_central_log_flag_destroy (void *ptr) +{ + if (ptr) + FREE (ptr); +} + + +int +glusterfs_central_log_flag_init () +{ + int ret = 0; + + ret = pthread_key_create (¢ral_log_flag_key, + glusterfs_central_log_flag_destroy); + + if (ret != 0) { + return ret; + } + + pthread_setspecific (central_log_flag_key, (void *) 0); + + return ret; +} + + +void +glusterfs_central_log_flag_set () +{ + pthread_setspecific (central_log_flag_key, (void *) 1); +} + + +long +glusterfs_central_log_flag_get () +{ + long flag = 0; + + flag = (long) pthread_getspecific (central_log_flag_key); + + return flag; +} + + +void +glusterfs_central_log_flag_unset () +{ + pthread_setspecific (central_log_flag_key, (void *) 0); +} + + int glusterfs_globals_init () { @@ -161,6 +216,10 @@ glusterfs_globals_init () ret = glusterfs_this_init (); if (ret) goto out; + + ret = glusterfs_central_log_flag_init (); + if (ret) + goto out; out: return ret; } |