summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2012-04-19 14:10:44 +0530
committerAnand Avati <avati@redhat.com>2012-04-23 18:54:55 -0700
commit7cc14db79d4579cfa50c30108fdf67ffa61cb94a (patch)
tree5adb59586251f3337398a6e6e6e0b30baa2c54ed /xlators
parent7c49e18bb58e91698630f95b67bd52e79ad391ca (diff)
glusterd,glusterfsd : Perform proper cleanup of connections and socket files
Perform proper disconnections and cleanup in glusterd on stopping nfs-server and self-heal daemon processes to prevent glusterd from opening unneded unix domain socket connections. glusterfsd processes will cleanup the socket files properly in cleanup_and_exit() to prevent junk socket files. Also, fix rpcsvc_program_unregister() to preform the unregistering properly. Change-Id: I1c7302c1166cf43feba1c7a813c3dc10169dc53a BUG: 810089 Signed-off-by: Kaushal M <kaushal@redhat.com> Reviewed-on: http://review.gluster.com/3168 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Krishnan Parthasarathi <kp@gluster.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c72
1 files changed, 63 insertions, 9 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index ed7ba1d51e6..73770bb76a9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -2783,20 +2783,41 @@ glusterd_nodesvc_connect (char *server, char *socketpath) {
dict_t *options = NULL;
struct rpc_clnt *rpc = NULL;
- ret = rpc_clnt_transport_unix_options_build (&options, socketpath);
- if (ret)
- goto out;
- ret = glusterd_rpc_create (&rpc, options,
- glusterd_nodesvc_rpc_notify,
- server);
- if (ret)
- goto out;
- (void) glusterd_nodesvc_set_rpc (server, rpc);
+ rpc = glusterd_nodesvc_get_rpc (server);
+
+ if (rpc == NULL) {
+ ret = rpc_clnt_transport_unix_options_build (&options,
+ socketpath);
+ if (ret)
+ goto out;
+ ret = glusterd_rpc_create (&rpc, options,
+ glusterd_nodesvc_rpc_notify,
+ server);
+ if (ret)
+ goto out;
+ (void) glusterd_nodesvc_set_rpc (server, rpc);
+ }
out:
return ret;
}
int32_t
+glusterd_nodesvc_disconnect (char *server)
+{
+ struct rpc_clnt *rpc = NULL;
+
+ rpc = glusterd_nodesvc_get_rpc (server);
+
+ if (rpc) {
+ rpc_clnt_connection_cleanup (&rpc->conn);
+ rpc_clnt_unref (rpc);
+ (void)glusterd_nodesvc_set_rpc (server, NULL);
+ }
+
+ return 0;
+}
+
+int32_t
glusterd_nodesvc_start (char *server)
{
int32_t ret = -1;
@@ -2910,6 +2931,31 @@ glusterd_is_nodesvc_running (char *server)
}
int32_t
+glusterd_nodesvc_unlink_socket_file (char *server)
+{
+ int ret = 0;
+ char sockfpath[PATH_MAX] = {0,};
+ char rundir[PATH_MAX] = {0,};
+ glusterd_conf_t *priv = THIS->private;
+
+ glusterd_get_nodesvc_rundir (server, priv->workdir,
+ rundir, sizeof (rundir));
+
+ glusterd_nodesvc_set_socket_filepath (rundir, priv->uuid,
+ sockfpath, sizeof (sockfpath));
+
+ ret = unlink (sockfpath);
+ if (ret && (ENOENT == errno)) {
+ ret = 0;
+ } else {
+ gf_log (THIS->name, GF_LOG_ERROR, "Failed to remove %s"
+ " error: %s", sockfpath, strerror (errno));
+ }
+
+ return ret;
+}
+
+int32_t
glusterd_nodesvc_stop (char *server, int sig)
{
char pidfile[PATH_MAX] = {0,};
@@ -2918,9 +2964,17 @@ glusterd_nodesvc_stop (char *server, int sig)
if (!glusterd_is_nodesvc_running (server))
goto out;
+
+ (void)glusterd_nodesvc_disconnect (server);
+
glusterd_get_nodesvc_pidfile (server, priv->workdir,
pidfile, sizeof (pidfile));
ret = glusterd_service_stop (server, pidfile, sig, _gf_true);
+
+ if (ret == 0) {
+ glusterd_nodesvc_set_running (server, _gf_false);
+ (void)glusterd_nodesvc_unlink_socket_file (server);
+ }
out:
return ret;
}