summaryrefslogtreecommitdiffstats
path: root/xlators/nfs/server/src
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendrabhat@gluster.com>2012-04-24 23:49:06 +0530
committerAnand Avati <avati@redhat.com>2012-05-21 18:33:26 -0700
commit25ee4c27d9beaac0bdbf640851639e12e8f625b2 (patch)
treea23e28ee770e9da91745b110ca95875cb57de4c8 /xlators/nfs/server/src
parentc7cc38b66f5e8581815d4d680190b96592313bc3 (diff)
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 <raghavendrabhat@gluster.com> Reviewed-on: http://review.gluster.com/3225 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/nfs/server/src')
-rw-r--r--xlators/nfs/server/src/nlm4.c24
-rw-r--r--xlators/nfs/server/src/nlm4.h2
2 files changed, 24 insertions, 2 deletions
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) {
diff --git a/xlators/nfs/server/src/nlm4.h b/xlators/nfs/server/src/nlm4.h
index bcc7ae57343..0cc82f162de 100644
--- a/xlators/nfs/server/src/nlm4.h
+++ b/xlators/nfs/server/src/nlm4.h
@@ -25,6 +25,8 @@
#include "config.h"
#endif
+#include <sys/types.h>
+#include <signal.h>
#include "rpcsvc.h"
#include "dict.h"
#include "xlator.h"