summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Jansa <djansa@redhat.com>2005-09-26 15:33:04 +0000
committerNathan Straz <nstraz@redhat.com>2008-09-23 09:37:45 -0400
commit31e5e577ce365e97c97a9834f87be8fbddf7b6d4 (patch)
treec936e4ed27d423318e73ab5348d5532796f6790d
parent52c768a1b14f28b35b50702db80dc6683a0d747a (diff)
downloadqarsh-31e5e577ce365e97c97a9834f87be8fbddf7b6d4.zip
qarsh-31e5e577ce365e97c97a9834f87be8fbddf7b6d4.tar.gz
qarsh-31e5e577ce365e97c97a9834f87be8fbddf7b6d4.tar.xz
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
-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) {