summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikas Gorur <vikas@gluster.com>2009-06-09 05:08:59 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-06-11 07:51:27 -0700
commite7e6144a7688b35255ef5d69b060bd90e319679f (patch)
tree903b1a062916088a55e8d820a6131a9f8758d941
parentf7ca417394aeb5a8c2144e3b2ae6493ef172b32d (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>
-rw-r--r--libglusterfs/src/globals.c59
-rw-r--r--libglusterfs/src/globals.h5
2 files changed, 64 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 (&central_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;
}
diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h
index f4d252dd9b5..2f284ca9b14 100644
--- a/libglusterfs/src/globals.h
+++ b/libglusterfs/src/globals.h
@@ -35,6 +35,11 @@ xlator_t **__glusterfs_this_location ();
xlator_t *glusterfs_this_get ();
int glusterfs_this_set (xlator_t *);
+void glusterfs_central_log_flag_set ();
+long glusterfs_central_log_flag_get ();
+void glusterfs_central_log_flag_unset ();
+
+
/* init */
int glusterfs_globals_init (void);