From f3648c88ebc6d58a10854d564d3fc2c82290ce13 Mon Sep 17 00:00:00 2001 From: Gaurav Date: Mon, 31 Jan 2011 04:25:23 +0000 Subject: Logging : New uuid to string conversion functions. Signed-off-by: Gaurav Signed-off-by: Anand V. Avati BUG: 2308 (Threadsafe uuid to string conversion function) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2308 --- libglusterfs/src/globals.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'libglusterfs/src/globals.c') diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c index 979f84e32..3121a1f14 100644 --- a/libglusterfs/src/globals.c +++ b/libglusterfs/src/globals.c @@ -305,6 +305,42 @@ synctask_set (void *synctask) return ret; } +//UUID_BUFFER + +static pthread_key_t uuid_buf_key; +static char global_uuid_buf[GF_UUID_BUF_SIZE]; +void +glusterfs_uuid_buf_destroy (void *ptr) +{ + if (ptr) + FREE (ptr); +} + +int +glusterfs_uuid_buf_init () +{ + int ret = 0; + + ret = pthread_key_create (&uuid_buf_key, + glusterfs_uuid_buf_destroy); + return ret; +} + +char * +glusterfs_uuid_buf_get () +{ + char *buf; + int ret = 0; + + buf = pthread_getspecific (uuid_buf_key); + if(!buf) { + buf = MALLOC (GF_UUID_BUF_SIZE); + ret = pthread_setspecific (uuid_buf_key, (void *) buf); + if(ret) + buf = global_uuid_buf; + } + return buf; +} int glusterfs_globals_init () @@ -325,6 +361,10 @@ glusterfs_globals_init () if (ret) goto out; + ret = glusterfs_uuid_buf_init (); + if(ret) + goto out; + gf_mem_acct_enable_set (); ret = synctask_init (); -- cgit