diff options
author | Kaushal M <kaushal@redhat.com> | 2012-04-19 14:10:44 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-04-23 18:54:55 -0700 |
commit | 7cc14db79d4579cfa50c30108fdf67ffa61cb94a (patch) | |
tree | 5adb59586251f3337398a6e6e6e0b30baa2c54ed /glusterfsd | |
parent | 7c49e18bb58e91698630f95b67bd52e79ad391ca (diff) | |
download | glusterfs-7cc14db79d4579cfa50c30108fdf67ffa61cb94a.tar.gz glusterfs-7cc14db79d4579cfa50c30108fdf67ffa61cb94a.tar.xz glusterfs-7cc14db79d4579cfa50c30108fdf67ffa61cb94a.zip |
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 'glusterfsd')
-rw-r--r-- | glusterfsd/src/glusterfsd-mgmt.c | 70 | ||||
-rw-r--r-- | glusterfsd/src/glusterfsd.c | 3 |
2 files changed, 44 insertions, 29 deletions
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index 814de1d934..dac92d67fb 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -192,37 +192,9 @@ glusterfs_terminate_response_send (rpcsvc_request_t *req, int op_ret) } int -glusterfs_listener_stop (void) -{ - glusterfs_ctx_t *ctx = NULL; - cmd_args_t *cmd_args = NULL; - int ret = 0; - xlator_t *this = NULL; - - ctx = glusterfs_ctx_get (); - GF_ASSERT (ctx); - cmd_args = &ctx->cmd_args; - if (cmd_args->sock_file) { - ret = unlink (cmd_args->sock_file); - if (ret && (ENOENT == errno)) { - ret = 0; - } - } - - if (ret) { - this = THIS; - gf_log (this->name, GF_LOG_ERROR, "Failed to unlink linstener " - "socket %s, error: %s", cmd_args->sock_file, - strerror (errno)); - } - return ret; -} - -int glusterfs_handle_terminate (rpcsvc_request_t *req) { - (void) glusterfs_listener_stop (); glusterfs_terminate_response_send (req, 0); cleanup_and_exit (SIGTERM); return 0; @@ -1792,6 +1764,48 @@ out: } int +glusterfs_listener_stop (glusterfs_ctx_t *ctx) +{ + cmd_args_t *cmd_args = NULL; + rpcsvc_t *rpc = NULL; + rpcsvc_listener_t *listener = NULL; + rpcsvc_listener_t *next = NULL; + int ret = 0; + xlator_t *this = NULL; + + GF_ASSERT (ctx); + + rpc = ctx->listener; + ctx->listener = NULL; + + (void) rpcsvc_program_unregister(rpc, &glusterfs_mop_prog); + + list_for_each_entry_safe (listener, next, &rpc->listeners, list) { + rpcsvc_listener_destroy (listener); + } + + (void) rpcsvc_unregister_notify (rpc, glusterfs_rpcsvc_notify, THIS); + + GF_FREE (rpc); + + cmd_args = &ctx->cmd_args; + if (cmd_args->sock_file) { + ret = unlink (cmd_args->sock_file); + if (ret && (ENOENT == errno)) { + ret = 0; + } + } + + if (ret) { + this = THIS; + gf_log (this->name, GF_LOG_ERROR, "Failed to unlink linstener " + "socket %s, error: %s", cmd_args->sock_file, + strerror (errno)); + } + return ret; +} + +int glusterfs_mgmt_init (glusterfs_ctx_t *ctx) { cmd_args_t *cmd_args = NULL; diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 7bc063b2fe..4ad47ec621 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -198,6 +198,7 @@ int glusterfs_pidfile_cleanup (glusterfs_ctx_t *ctx); int glusterfs_volumes_init (glusterfs_ctx_t *ctx); int glusterfs_mgmt_init (glusterfs_ctx_t *ctx); int glusterfs_listener_init (glusterfs_ctx_t *ctx); +int glusterfs_listener_stop (glusterfs_ctx_t *ctx); int create_fuse_mount (glusterfs_ctx_t *ctx) @@ -798,7 +799,7 @@ cleanup_and_exit (int signum) ctx->cleanup_started = 1; glusterfs_mgmt_pmap_signout (ctx); if (ctx->listener) { - ctx->listener = NULL; + (void) glusterfs_listener_stop (ctx); } /* Call fini() of FUSE xlator first: |