HomeClusterLabs Projects

Refactor: pacemakerd: Simplify child_liveness() somewhat

Description

Refactor: pacemakerd: Simplify child_liveness() somewhat

Check for child->pid == 0 instead of child->pid <= 0. If child->pid !=
0, then it's been initialized successfully. In practice, the PID of a
single process shouldn't be negative as far as I know. But checking != 0
seems clearer and seems more consistent with the rest of the file.

Previously, the possibilities were as follows:

  • pcmk_rc_ipc_unresponsive:
    • child->pid <= 0: Then child->pid == 0 in practice, and we set child->pid to ipc_pid. Since rc is pcmk_rc_ipc_unresponsive, ipc_pid should be 0. So the assignment is a no-op. Thus we skip it now. rc doesn't change, so we move on to the next stage.
    • child->pid > 0: Then rc doesn't change, so we move on to the next stage.
  • pcmk_rc_ok:
    • child->pid <= 0: Then we set child->pid to ipc_pid, which is nonzero since rc is pcmk_rc_ok.
    • child->pid > 0:
      • child->pid == ipc_pid: Then rc doesn't change. Since rc is still pcmk_rc_ok, we return.
      • child->pid != ipc_pid: Then we set rc to pcmk_rc_ipc_unresponsive, so that we move on to the next stage of "investigation."

Note that rc didn't change if it was pcmk_rc_ipc_unresponsive. So we
could return early here only if rc was pcmk_rc_ok. We take advantage of
that in this commit.

Also drop "a child without IPC is being tracked" from a comment. Suppose
child->pid == 0 when we entered this function. If we reached this point,
then no IPC liveness was detected. If IPC liveness had been detected,
then that means rc was pcmk_rc_ok. Then since child->pid was 0, we would
have set it to ipc_pid and returned.

So the only two possibilities are that no liveness was detected or that
an unexpected process was found.

I don't know what the "This is safe on FreeBSD" sentence is supposed to
mean, so I left it alone.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>

Details

Provenance
nrwahl2Authored on Tue, Sep 16, 9:56 PM
Parents
rP4d0d105930c9: Refactor: pacemakerd: Remove more nesting in child_liveness()
Branches
Unknown
Tags
Unknown