From 25ee4c27d9beaac0bdbf640851639e12e8f625b2 Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Tue, 24 Apr 2012 23:49:06 +0530 Subject: nlm: do not use killall command to kill rpc.statd killall command will kill the rpc.statd process only in normal mode. If the process is running in valgrind mode, then killall is not able to kill rpc.statd and several instances of rpc.statd will be running for every restart of the nfs server (graph changes etc). So to avoid that get the pid of rpc.statd using /var/run/rpc.statd.pid and send SIGKILL signal to that pid to accomplish what killall command was doing. Change-Id: I2509bf918ddd0dcdd9a4562ee23f13488c7a5979 BUG: 815756 Signed-off-by: Raghavendra Bhat Reviewed-on: http://review.gluster.com/3225 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Anand Avati --- xlators/nfs/server/src/nlm4.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'xlators/nfs/server/src/nlm4.c') diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c index 7eb95a7a553..a4afc257e25 100644 --- a/xlators/nfs/server/src/nlm4.c +++ b/xlators/nfs/server/src/nlm4.c @@ -2355,6 +2355,8 @@ nlm4svc_init(xlator_t *nfsx) char *portstr = NULL; pthread_t thr; struct timeval timeout = {0,}; + FILE *pidfile = NULL; + pid_t pid = -1; nfs = (struct nfs_state*)nfsx->private; @@ -2421,8 +2423,26 @@ nlm4svc_init(xlator_t *nfsx) * Need to figure out a more graceful way * killall will cause problems on solaris. */ - ret = runcmd ("killall", "-9", "rpc.statd", NULL); - /* if ret == -1, do nothing - case statd was not already running */ + + pidfile = fopen ("/var/run/rpc.statd.pid", "r"); + if (pidfile) { + ret = fscanf (pidfile, "%d", &pid); + if (ret <= 0) { + gf_log (GF_NLM, GF_LOG_WARNING, "unable to get pid of " + "rpc.statd"); + ret = runcmd ("killall", "-9", "rpc.statd", NULL); + } else + kill (pid, SIGKILL); + + fclose (pidfile); + } else { + gf_log (GF_NLM, GF_LOG_WARNING, "opening the pid file of " + "rpc.statd failed (%s)", strerror (errno)); + /* if ret == -1, do nothing - case either statd was not + * running or was running in valgrind mode + */ + ret = runcmd ("killall", "-9", "rpc.statd", NULL); + } ret = unlink ("/var/run/rpc.statd.pid"); if (ret == -1 && errno != ENOENT) { -- cgit