summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2012-07-16 14:03:06 -0700
committerAnand Avati <avati@redhat.com>2012-07-17 12:29:36 -0700
commitea0a0937a0524b8a449e470fbaea772a349d40fb (patch)
tree66ed7cbc48ec80633cecaa5740f53985499871b8 /cli
parent24717f14fa9e409f01f89c0905163b0db1e40729 (diff)
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 <avati@redhat.com> Reviewed-on: http://review.gluster.com/3677 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli.c37
1 files changed, 1 insertions, 36 deletions
diff --git a/cli/src/cli.c b/cli/src/cli.c
index 0d9582dcb8c..1a2081edca1 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -99,41 +99,6 @@ rpc_clnt_prog_t *cli_rpc_prog;
extern struct rpc_clnt_program cli_prog;
-
-
-
-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, 256) == -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:%"
-#ifdef GF_DARWIN_HOST_OS
- PRId32,
-#else
- "ld",
-#endif
- hostname, getpid(), now_str, tv.tv_usec);
-
- return gf_strdup (tmp_str);
-}
-
static int
glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
{
@@ -143,7 +108,7 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
xlator_mem_acct_init (THIS, cli_mt_end);
- ctx->process_uuid = generate_uuid ();
+ ctx->process_uuid = generate_glusterfs_ctx_id ();
if (!ctx->process_uuid)
return -1;