diff options
| author | Pranith Kumar K <pranithk@gluster.com> | 2010-09-24 04:38:36 +0000 | 
|---|---|---|
| committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-24 03:54:04 -0700 | 
| commit | f2c5894f254d9b3d17b058adce7c7b4152da2f5e (patch) | |
| tree | e27d446452b2592270f148e2de3b7caa408bf8a6 | |
| parent | 0cf88c1d35bbc86fdfc1b8035222b248d6725807 (diff) | |
mgmt/glusterd: add option to force kill gnfs process
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1517 (gluster volume stop - starts a new nfs server.)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1517
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 37 | ||||
| -rw-r--r-- | 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);  | 
