diff options
Diffstat (limited to 'libglusterfs/src/globals.c')
-rw-r--r-- | libglusterfs/src/globals.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c index 435921d64cc..0645ffadb10 100644 --- a/libglusterfs/src/globals.c +++ b/libglusterfs/src/globals.c @@ -69,6 +69,7 @@ const char *gf_fop_list[GF_FOP_MAXVALUE] = { [GF_FOP_ZEROFILL] = "ZEROFILL", [GF_FOP_IPC] = "IPC", [GF_FOP_SEEK] = "SEEK", + [GF_FOP_LEASE] = "LEASE", }; /* THIS */ @@ -84,6 +85,7 @@ static pthread_key_t uuid_buf_key; static char global_uuid_buf[GF_UUID_BUF_SIZE]; static pthread_key_t lkowner_buf_key; static char global_lkowner_buf[GF_LKOWNER_BUF_SIZE]; +static pthread_key_t leaseid_buf_key; static int gf_global_mem_acct_enable = 1; static pthread_once_t globals_inited = PTHREAD_ONCE_INIT; @@ -335,6 +337,41 @@ glusterfs_lkowner_buf_get () return buf; } +/* Leaseid buffer */ +void +glusterfs_leaseid_buf_destroy (void *ptr) +{ + FREE (ptr); +} + +int +glusterfs_leaseid_buf_init () +{ + int ret = 0; + + ret = pthread_key_create (&leaseid_buf_key, + glusterfs_leaseid_buf_destroy); + return ret; +} + +char * +glusterfs_leaseid_buf_get () +{ + char *buf = NULL; + int ret = 0; + + buf = pthread_getspecific (leaseid_buf_key); + if (!buf) { + buf = CALLOC (1, GF_LEASE_ID_BUF_SIZE); + ret = pthread_setspecific (leaseid_buf_key, (void *) buf); + if (ret) { + FREE (buf); + buf = NULL; + } + } + return buf; +} + static void gf_globals_init_once () { @@ -361,6 +398,13 @@ gf_globals_init_once () goto out; } + ret = glusterfs_leaseid_buf_init (); + if (ret) { + gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_LEASEID_BUF_INIT_FAILED, + "ERROR: glusterfs leaseid buffer init failed"); + goto out; + } + ret = synctask_init (); if (ret) { gf_msg ("", GF_LOG_CRITICAL, 0, LG_MSG_SYNCTASK_INIT_FAILED, |