Skip to content

Commit

Permalink
Fix: crm_mon: Ensure stale pid files are updated when a new process i…
Browse files Browse the repository at this point in the history
…s started
  • Loading branch information
beekhof committed May 1, 2013
1 parent 53ac70e commit e549770
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/common/utils.c
Expand Up @@ -1309,15 +1309,22 @@ crm_pidfile_inuse(const char *filename, long mypid)
}
if (read(fd, buf, sizeof(buf)) > 0) {
if (sscanf(buf, "%lu", &pid) > 0) {
crm_trace("Got pid %lu from %s\n", pid, filename);
if (pid <= 1) {
/* Invalid pid */
rc = -ENOENT;
unlink(filename);

} else if (mypid && pid == mypid) {
/* In use by us */
rc = pcmk_ok;

} else if (mypid && pid != mypid && crm_pid_active(pid)) {
} else if (crm_pid_active(pid) == FALSE) {
/* Contains a stale value */
unlink(filename);
rc = -ENOENT;

} else if (mypid && pid != mypid) {
/* locked by existing process - give up */
rc = -EEXIST;
}
Expand Down

0 comments on commit e549770

Please sign in to comment.