diff options
author | Csaba Henk <csaba@redhat.com> | 2012-05-29 17:21:34 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-05-31 14:23:47 -0700 |
commit | cd88d3db0f48c4354711a606937a2f0b9ba7f87a (patch) | |
tree | 4de5753420dde7847aa26e53f9e3dded47333b9c /xlators/mgmt/glusterd | |
parent | f2a3291c2fe5a00bca1e4a77a37560ec30cc24bf (diff) |
glusterd: cut out a standalone socket path calculation routine
Change-Id: If5f196c9154ea59e37b83d3e4cad445fee6e9d45
BUG: 826512
Signed-off-by: Csaba Henk <csaba@redhat.com>
Reviewed-on: http://review.gluster.com/3490
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pranithk@gluster.com>
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 20 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 3 |
2 files changed, 16 insertions, 7 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index f2d96e36364..b3b39a1f59b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -1050,13 +1050,21 @@ out: } void +glusterd_set_socket_filepath (char *sock_filepath, char *sockpath, size_t len) +{ + char md5_sum[MD5_DIGEST_LENGTH*2+1] = {0,}; + + md5_wrapper ((unsigned char *) sock_filepath, strlen(sock_filepath), md5_sum); + snprintf (sockpath, len, "%s/%s.socket", glusterd_sock_dir, md5_sum); +} + +void glusterd_set_brick_socket_filepath (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo, char *sockpath, size_t len) { char export_path[PATH_MAX] = {0,}; char sock_filepath[PATH_MAX] = {0,}; - char md5_sum[MD5_DIGEST_LENGTH*2+1] = {0,}; char volume_dir[PATH_MAX] = {0,}; xlator_t *this = NULL; glusterd_conf_t *priv = NULL; @@ -1074,8 +1082,8 @@ glusterd_set_brick_socket_filepath (glusterd_volinfo_t *volinfo, GLUSTERD_REMOVE_SLASH_FROM_PATH (brickinfo->path, export_path); snprintf (sock_filepath, PATH_MAX, "%s/run/%s-%s", volume_dir, brickinfo->hostname, export_path); - md5_wrapper ((unsigned char *) sock_filepath, strlen(sock_filepath), md5_sum); - snprintf (sockpath, len, "%s/%s.socket", glusterd_sock_dir, md5_sum); + + glusterd_set_socket_filepath (sock_filepath, sockpath, len); } /* connection happens only if it is not aleady connected, @@ -2699,13 +2707,11 @@ glusterd_nodesvc_set_socket_filepath (char *rundir, uuid_t uuid, char *socketpath, int len) { char sockfilepath[PATH_MAX] = {0,}; - char md5_str[MD5_DIGEST_LENGTH*2+1] = {0,}; snprintf (sockfilepath, sizeof (sockfilepath), "%s/run-%s", rundir, uuid_utoa (uuid)); - md5_wrapper ((unsigned char *) sockfilepath, strlen (sockfilepath), md5_str); - snprintf (socketpath, len, "%s/%s.socket", glusterd_sock_dir, - md5_str); + + glusterd_set_socket_filepath (sockfilepath, socketpath, len); return 0; } diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index 0297d9a22eb..0990ae5247d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -195,6 +195,9 @@ glusterd_shd_start (); int32_t glusterd_shd_stop (); +void +glusterd_set_socket_filepath (char *sock_filepath, char *sockpath, size_t len); + int32_t glusterd_nodesvc_set_socket_filepath (char *rundir, uuid_t uuid, char *socketpath, int len); |