summaryrefslogtreecommitdiffstats
path: root/qarsh.c
diff options
context:
space:
mode:
Diffstat (limited to 'qarsh.c')
-rw-r--r--qarsh.c21
1 files 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) {