diff options
author | Nate Straz <nstraz@redhat.com> | 2006-01-06 16:42:28 +0000 |
---|---|---|
committer | Nathan Straz <nstraz@redhat.com> | 2008-09-23 09:37:45 -0400 |
commit | 65794221d4d9890a2536c6bb95301466e9707592 (patch) | |
tree | a294437da307cf4b843ed9cbe27393018af2b33b /hbeat.c | |
parent | f73014e353921cf45c124383991a59b436145836 (diff) | |
download | qarsh-65794221d4d9890a2536c6bb95301466e9707592.tar.gz qarsh-65794221d4d9890a2536c6bb95301466e9707592.tar.xz qarsh-65794221d4d9890a2536c6bb95301466e9707592.zip |
Reorganized heartbeat state machine to be move explicit.
Don't set last_rhost_btime until after we've checked for a reboot.
Diffstat (limited to 'hbeat.c')
-rw-r--r-- | hbeat.c | 48 |
1 files changed, 28 insertions, 20 deletions
@@ -96,8 +96,33 @@ hbeat(hbeat_t hbh) hbeat = btime(hbeatp->host); current_time = time(NULL); - if (!hbeat) { - switch (hbeatp->rhost_state) { + if (hbeat) { switch(hbeatp->rhost_state) { + /* Remote Host is Responding */ + case HOST_REBOOT: + case HOST_TIMEOUT: + retval = 0; + break; + case HOST_QUIET: + hbeatp->rhost_state = HOST_ALIVE; + hbeatp->start_quiet_time = 0; + case HOST_ALIVE: + if (hbeatp->last_rhost_btime == 0) { + hbeatp->last_rhost_btime = hbeat; + retval = 1; + } else if (abs(hbeat - hbeatp->last_rhost_btime) > 5) { + hbeatp->rhost_state = HOST_REBOOT; + retval = 0; + } else { + hbeatp->last_rhost_btime = hbeat; + retval = 1; + } + break; + + case HOST_HBEAT_DISABLED: + retval = 1; + break; + }} else { switch (hbeatp->rhost_state) { + /* Remote Host is NOT Responding */ case HOST_ALIVE: hbeatp->rhost_state = HOST_QUIET; hbeatp->start_quiet_time = time(NULL); @@ -122,24 +147,7 @@ hbeat(hbeat_t hbh) case HOST_HBEAT_DISABLED: retval = 1; break; - } - } - - if (hbeat) { - if (hbeatp->rhost_state == HOST_REBOOT) { - retval = 0; - } else { - hbeatp->last_rhost_btime = hbeat; - hbeatp->rhost_state = HOST_ALIVE; - hbeatp->start_quiet_time = 0; - retval = 1; - - if (abs(hbeat - hbeatp->last_rhost_btime) > 5) { - hbeatp->rhost_state = HOST_REBOOT; - retval = 0; - } - } - } + }} return retval; } |