diff options
| author | Gaurav <gaurav@gluster.com> | 2011-01-31 04:25:23 +0000 | 
|---|---|---|
| committer | Anand V. Avati <avati@dev.gluster.com> | 2011-02-04 00:39:20 -0800 | 
| commit | f3648c88ebc6d58a10854d564d3fc2c82290ce13 (patch) | |
| tree | bf7d14ba0ae498e96d39fdd35d0f47c75b860acc /libglusterfs/src/globals.c | |
| parent | ba40a3ece0a0b5b381e7d05c74d09cdd1818b817 (diff) | |
Logging : New uuid to string conversion functions.
Signed-off-by: Gaurav <gaurav@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 2308 (Threadsafe uuid to string conversion function)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2308
Diffstat (limited to 'libglusterfs/src/globals.c')
| -rw-r--r-- | libglusterfs/src/globals.c | 40 | 
1 files changed, 40 insertions, 0 deletions
diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c index 979f84e3296..3121a1f1415 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 ();  | 
