From 31e5e577ce365e97c97a9834f87be8fbddf7b6d4 Mon Sep 17 00:00:00 2001 From: Dean Jansa Date: Mon, 26 Sep 2005 15:33:04 +0000 Subject: 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 --- qarsh.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/qarsh.c b/qarsh.c index 3f7e5a7..bd61c24 100644 --- a/qarsh.c +++ b/qarsh.c @@ -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) { -- cgit