diff options
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 48 |
1 files changed, 7 insertions, 41 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 5b69316b..27a8990e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -1026,7 +1026,7 @@ glusterd_service_stop (const char *service, char *pidfile, int sig, this = THIS; GF_ASSERT (this); - if (!glusterd_is_service_running (pidfile, &pid)) { + if (!gf_is_service_running (pidfile, &pid)) { ret = 0; gf_log (this->name, GF_LOG_INFO, "%s already stopped", service); goto out; @@ -1039,7 +1039,7 @@ glusterd_service_stop (const char *service, char *pidfile, int sig, goto out; sleep (1); - if (glusterd_is_service_running (pidfile, NULL)) { + if (gf_is_service_running (pidfile, NULL)) { ret = kill (pid, SIGKILL); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Unable to " @@ -1205,7 +1205,7 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo, if (ret) goto out; GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, priv); - if (glusterd_is_service_running (pidfile, NULL)) + if (gf_is_service_running (pidfile, NULL)) goto connect; _reap_brick_process (pidfile, brickinfo->path); @@ -3090,40 +3090,6 @@ out: return ret; } -/* Valid only in if service is 'local' to glusterd. - * pid can be -1, if reading pidfile failed */ -gf_boolean_t -glusterd_is_service_running (char *pidfile, int *pid) -{ - FILE *file = NULL; - gf_boolean_t running = _gf_false; - int ret = 0; - int fno = 0; - - file = fopen (pidfile, "r+"); - if (!file) - goto out; - - fno = fileno (file); - ret = lockf (fno, F_TEST, 0); - if (ret == -1) - running = _gf_true; - if (!pid) - goto out; - - ret = fscanf (file, "%d", pid); - if (ret <= 0) { - gf_log ("", GF_LOG_ERROR, "Unable to read pidfile: %s, %s", - pidfile, strerror (errno)); - *pid = -1; - } - -out: - if (file) - fclose (file); - return running; -} - void glusterd_get_nodesvc_dir (char *server, char *workdir, char *path, size_t len) @@ -3481,7 +3447,7 @@ glusterd_is_nodesvc_running (char *server) glusterd_get_nodesvc_pidfile (server, priv->workdir, pidfile, sizeof (pidfile)); - return glusterd_is_service_running (pidfile, NULL); + return gf_is_service_running (pidfile, NULL); } int32_t @@ -3612,7 +3578,7 @@ glusterd_add_node_to_dict (char *server, dict_t *dict, int count, sizeof (pidfile)); //Consider service to be running only when glusterd sees it Online if (glusterd_is_nodesvc_online (server)) - running = glusterd_is_service_running (pidfile, &pid); + running = gf_is_service_running (pidfile, &pid); /* For nfs-servers/self-heal-daemon setting * brick<n>.hostname = "NFS Server" / "Self-heal Daemon" @@ -4599,7 +4565,7 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo, GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, priv); - brick_online = glusterd_is_service_running (pidfile, &pid); + brick_online = gf_is_service_running (pidfile, &pid); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.pid", base_key); @@ -6119,7 +6085,7 @@ glusterd_volume_defrag_restart (glusterd_volinfo_t *volinfo, char *op_errstr, GLUSTERD_GET_DEFRAG_PID_FILE(pidfile, volinfo, priv); - if (!glusterd_is_service_running (pidfile, &pid)) { + if (!gf_is_service_running (pidfile, &pid)) { glusterd_handle_defrag_start (volinfo, op_errstr, len, cmd, cbk, volinfo->rebal.op); } else { |