diff options
author | Dean Jansa <djansa@redhat.com> | 2005-09-26 15:33:04 +0000 |
---|---|---|
committer | Nathan Straz <nstraz@redhat.com> | 2008-09-23 09:37:45 -0400 |
commit | 31e5e577ce365e97c97a9834f87be8fbddf7b6d4 (patch) | |
tree | c936e4ed27d423318e73ab5348d5532796f6790d /qarsh.c | |
parent | 52c768a1b14f28b35b50702db80dc6683a0d747a (diff) | |
download | qarsh-31e5e577ce365e97c97a9834f87be8fbddf7b6d4.tar.gz qarsh-31e5e577ce365e97c97a9834f87be8fbddf7b6d4.tar.xz qarsh-31e5e577ce365e97c97a9834f87be8fbddf7b6d4.zip |
Fix a bug in heartbeat(). Need to reset host state when we got some IO from the host, and we only want to check for timeout if we were already in HOST_QUIET
Diffstat (limited to 'qarsh.c')
-rw-r--r-- | qarsh.c | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -153,18 +153,18 @@ heartbeat(const char *host) hbeat = btime(host); current_time = time(NULL); - if (hbeat == 0) { - qarsh_hbeat.rhost_state = HOST_QUIET; - if (qarsh_hbeat.start_quiet_time == 0) { - qarsh_hbeat.start_quiet_time = time(NULL); - } else { - if (current_time - qarsh_hbeat.start_quiet_time - > qarsh_hbeat.max_timeout) { - qarsh_hbeat.rhost_state = HOST_TIMEOUT; - return 0; - } + if (!hbeat && (qarsh_hbeat.rhost_state == HOST_QUIET)) { + if (current_time - qarsh_hbeat.start_quiet_time + > qarsh_hbeat.max_timeout) { + qarsh_hbeat.rhost_state = HOST_TIMEOUT; + return 0; } } else { + qarsh_hbeat.rhost_state = HOST_QUIET; + qarsh_hbeat.start_quiet_time = time(NULL); + } + + if (hbeat) { if (qarsh_hbeat.last_rhost_btime == 0) { qarsh_hbeat.last_rhost_btime = hbeat; qarsh_hbeat.rhost_state = HOST_ALIVE; @@ -303,6 +303,7 @@ run_remote_cmd(char *cmdline) signal_to_send = 0; } } else if (nset > 0) { + qarsh_hbeat.rhost_state = HOST_ALIVE; if (nset && FD_ISSET(fileno(stdin), &testfds)) { bufsize = read(fileno(stdin), buf, 1024); if (bufsize > 0) { |