From ea0a0937a0524b8a449e470fbaea772a349d40fb Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Mon, 16 Jul 2012 14:03:06 -0700 Subject: common-utils: implement generate_glusterfs_ctx_id() This patch creates a common and shared version of the often copy/ pasted generate_uuid() function, which is used to create an ID string to uniquely identify an instance of a glusterfs process/glusterfs_ctx_t. Change-Id: Ie4e697ae28b6e954c5c261c69e37738f289d77e4 BUG: 839950 Signed-off-by: Anand Avati Reviewed-on: http://review.gluster.com/3677 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi --- glusterfsd/src/glusterfsd.c | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) (limited to 'glusterfsd') diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index acbed554..c9c7ad06 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -941,34 +941,6 @@ reincarnate (int signum) } -static char * -generate_uuid () -{ - char tmp_str[1024] = {0,}; - char hostname[256] = {0,}; - struct timeval tv = {0,}; - char now_str[32]; - - if (gettimeofday (&tv, NULL) == -1) { - gf_log ("glusterfsd", GF_LOG_ERROR, - "gettimeofday: failed %s", - strerror (errno)); - } - - if (gethostname (hostname, sizeof hostname) == -1) { - gf_log ("glusterfsd", GF_LOG_ERROR, - "gethostname: failed %s", - strerror (errno)); - } - - gf_time_fmt (now_str, sizeof now_str, tv.tv_sec, gf_timefmt_Ymd_T); - snprintf (tmp_str, sizeof tmp_str, "%s-%d-%s:%" GF_PRI_SUSECONDS, - hostname, getpid(), now_str, tv.tv_usec); - - return gf_strdup (tmp_str); -} - - static uint8_t gf_get_process_mode (char *exec_name) { @@ -1064,7 +1036,7 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx) xlator_mem_acct_init (THIS, gfd_mt_end); - ctx->process_uuid = generate_uuid (); + ctx->process_uuid = generate_glusterfs_ctx_id (); if (!ctx->process_uuid) { gf_log ("", GF_LOG_CRITICAL, "ERROR: glusterfs uuid generation failed"); -- cgit