From f2c5894f254d9b3d17b058adce7c7b4152da2f5e Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Fri, 24 Sep 2010 04:38:36 +0000 Subject: mgmt/glusterd: add option to force kill gnfs process Signed-off-by: Pranith Kumar K Signed-off-by: Vijay Bellur BUG: 1517 (gluster volume stop - starts a new nfs server.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1517 --- xlators/mgmt/glusterd/src/glusterd-utils.c | 37 ++++++++++++++++-------------- xlators/mgmt/glusterd/src/glusterd-utils.h | 2 +- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index a59a06905bd..411d21765e9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -769,8 +769,8 @@ glusterd_volinfo_find (char *volname, glusterd_volinfo_t **volinfo) int32_t -glusterd_service_stop(const char *service, char *pidfile, int sig, - gf_boolean_t keep_pidfile) +glusterd_service_stop (const char *service, char *pidfile, int sig, + gf_boolean_t force_kill) { int32_t ret = -1; pid_t pid = -1; @@ -806,20 +806,23 @@ glusterd_service_stop(const char *service, char *pidfile, int sig, ret = kill (pid, sig); - if (ret) { - gf_log ("", GF_LOG_ERROR, "Unable to kill pid %d", pid); - goto out; - } - - if (keep_pidfile) - goto out; - - ret = unlink (pidfile); - - if (ret && (ENOENT != errno)) { - gf_log ("", GF_LOG_ERROR, "Unable to unlink pidfile: %s", - pidfile); - goto out; + if (force_kill) { + sleep (1); + ret = access (pidfile, F_OK); + if (!ret) { + ret = kill (pid, SIGKILL); + if (ret) { + gf_log ("", GF_LOG_ERROR, "Unable to " + "kill pid %d", pid); + goto out; + } + ret = unlink (pidfile); + if (ret && (ENOENT != errno)) { + gf_log ("", GF_LOG_ERROR, "Unable to " + "unlink pidfile: %s", pidfile); + goto out; + } + } } ret = 0; @@ -1642,7 +1645,7 @@ glusterd_nfs_server_stop () GLUSTERD_GET_NFS_DIR(path, priv); GLUSTERD_GET_NFS_PIDFILE(pidfile); - return glusterd_service_stop ("nfsd", pidfile, SIGTERM, _gf_false); + return glusterd_service_stop ("nfsd", pidfile, SIGTERM, _gf_true); } int diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index bc20c2d35c8..3f49acfda43 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -92,7 +92,7 @@ glusterd_volinfo_find (char *volname, glusterd_volinfo_t **volinfo); int32_t glusterd_service_stop(const char *service, char *pidfile, int sig, - gf_boolean_t keep_pidfile); + gf_boolean_t force_kill); int32_t glusterd_resolve_brick (glusterd_brickinfo_t *brickinfo); -- cgit