diff options
| -rw-r--r-- | cli/src/cli.c | 37 | ||||
| -rw-r--r-- | glusterfsd/src/glusterfsd.c | 30 | ||||
| -rw-r--r-- | libglusterfs/src/common-utils.c | 33 | ||||
| -rw-r--r-- | libglusterfs/src/common-utils.h | 2 | 
4 files changed, 37 insertions, 65 deletions
diff --git a/cli/src/cli.c b/cli/src/cli.c index 0d9582dcb..1a2081edc 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; diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index acbed554d..c9c7ad065 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"); diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index d09cafc68..cd7045277 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -2150,3 +2150,36 @@ _gf_timestuff (gf_timefmts *fmt, const char ***fmts, const char ***zeros)          *zeros = __gf_zerotimes;  } + +char * +generate_glusterfs_ctx_id (void) +{ +        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); +} + diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index 26af45fcc..f21ade40b 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -552,4 +552,6 @@ void gf_path_strip_trailing_slashes (char *path);  uint64_t get_mem_size ();  int gf_strip_whitespace (char *str, int len);  int gf_canonicalize_path (char *path); +char *generate_glusterfs_ctx_id (void); +  #endif /* _COMMON_UTILS_H */  | 
