diff options
-rw-r--r-- | glusterfsd/src/glusterfsd.c | 22 | ||||
-rw-r--r-- | libglusterfs/src/common-utils.c | 3 |
2 files changed, 18 insertions, 7 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index b868c05b927..f0eab620af5 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -2403,9 +2403,6 @@ daemonize(glusterfs_ctx_t *ctx) goto out; if (cmd_args->no_daemon_mode) { - ret = glusterfs_pidfile_update(ctx, getpid()); - if (ret) - goto out; goto postfork; } @@ -2461,13 +2458,26 @@ daemonize(glusterfs_ctx_t *ctx) will be available to parent process on calling exit() */ if (err) _exit(abs(err)); - ret = glusterfs_pidfile_update(ctx, child_pid); - if (ret) - _exit(1); + + /* Update pid in parent only for glusterd process */ + if (ctx->process_mode == GF_GLUSTERD_PROCESS) { + ret = glusterfs_pidfile_update(ctx, child_pid); + if (ret) + exit(1); + } _exit(0); } postfork: + /* Update pid in child either process_mode is not belong to glusterd + or process is spawned in no daemon mode + */ + if ((ctx->process_mode != GF_GLUSTERD_PROCESS) || + (cmd_args->no_daemon_mode)) { + ret = glusterfs_pidfile_update(ctx, getpid()); + if (ret) + goto out; + } ret = gf_log_inject_timer_event(ctx); glusterfs_signals_setup(ctx); diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index eefb5f159fe..ad3d308d92a 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -4066,7 +4066,6 @@ gf_is_service_running(char *pidfile, int *pid) ret = lockf(fno, F_TEST, 0); if (ret == -1) { running = _gf_true; - goto out; } ret = fscanf(file, "%d", pid); @@ -4074,6 +4073,8 @@ gf_is_service_running(char *pidfile, int *pid) gf_msg("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED, "Unable to read pidfile: %s", pidfile); *pid = -1; + running = _gf_false; + goto out; } running = gf_is_pid_running(*pid); |