From e7e6144a7688b35255ef5d69b060bd90e319679f Mon Sep 17 00:00:00 2001 From: Vikas Gorur Date: Tue, 9 Jun 2009 05:08:59 +0000 Subject: 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 --- libglusterfs/src/globals.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'libglusterfs/src/globals.c') diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c index 38727a25a..ae7fdcd61 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; } -- cgit