Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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>
  • Loading branch information...
commit cd88d3db0f48c4354711a606937a2f0b9ba7f87a 1 parent f2a3291
Csaba Henk authored avati committed
View
20 xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -1050,13 +1050,21 @@ glusterd_service_stop (const char *service, char *pidfile, int sig,
}
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;
}
View
3  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);
Please sign in to comment.
Something went wrong with that request. Please try again.