diff options
author | Colin Watson <cjwatson@debian.org> | 2014-02-09 16:09:51 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2015-11-29 17:26:12 +0000 |
commit | f1b6288dd90b72d4cad7e65f35d05148a5ba1874 (patch) | |
tree | 397a87d747e7a744ac1e5a54e3de315b7df2f2ea | |
parent | 89dd60ab74e7ebfe4f234c4068fa941479535d8e (diff) |
Partial server keep-alive implementation for SSH1
Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1712
Last-Update: 2013-09-14
Patch-Name: ssh1-keepalive.patch
-rw-r--r-- | clientloop.c | 25 | ||||
-rw-r--r-- | ssh_config.5 | 5 |
2 files changed, 19 insertions, 11 deletions
diff --git a/clientloop.c b/clientloop.c index fba1b5496..9e45d24e0 100644 --- a/clientloop.c +++ b/clientloop.c | |||
@@ -578,16 +578,21 @@ client_global_request_reply(int type, u_int32_t seq, void *ctxt) | |||
578 | static void | 578 | static void |
579 | server_alive_check(void) | 579 | server_alive_check(void) |
580 | { | 580 | { |
581 | if (packet_inc_alive_timeouts() > options.server_alive_count_max) { | 581 | if (compat20) { |
582 | logit("Timeout, server %s not responding.", host); | 582 | if (packet_inc_alive_timeouts() > options.server_alive_count_max) { |
583 | cleanup_exit(255); | 583 | logit("Timeout, server %s not responding.", host); |
584 | cleanup_exit(255); | ||
585 | } | ||
586 | packet_start(SSH2_MSG_GLOBAL_REQUEST); | ||
587 | packet_put_cstring("keepalive@openssh.com"); | ||
588 | packet_put_char(1); /* boolean: want reply */ | ||
589 | packet_send(); | ||
590 | /* Insert an empty placeholder to maintain ordering */ | ||
591 | client_register_global_confirm(NULL, NULL); | ||
592 | } else { | ||
593 | packet_send_ignore(0); | ||
594 | packet_send(); | ||
584 | } | 595 | } |
585 | packet_start(SSH2_MSG_GLOBAL_REQUEST); | ||
586 | packet_put_cstring("keepalive@openssh.com"); | ||
587 | packet_put_char(1); /* boolean: want reply */ | ||
588 | packet_send(); | ||
589 | /* Insert an empty placeholder to maintain ordering */ | ||
590 | client_register_global_confirm(NULL, NULL); | ||
591 | } | 596 | } |
592 | 597 | ||
593 | /* | 598 | /* |
@@ -649,7 +654,7 @@ client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, | |||
649 | */ | 654 | */ |
650 | 655 | ||
651 | timeout_secs = INT_MAX; /* we use INT_MAX to mean no timeout */ | 656 | timeout_secs = INT_MAX; /* we use INT_MAX to mean no timeout */ |
652 | if (options.server_alive_interval > 0 && compat20) { | 657 | if (options.server_alive_interval > 0) { |
653 | timeout_secs = options.server_alive_interval; | 658 | timeout_secs = options.server_alive_interval; |
654 | server_alive_time = now + options.server_alive_interval; | 659 | server_alive_time = now + options.server_alive_interval; |
655 | } | 660 | } |
diff --git a/ssh_config.5 b/ssh_config.5 index b2dc49b09..82dcf0c08 100644 --- a/ssh_config.5 +++ b/ssh_config.5 | |||
@@ -1468,7 +1468,10 @@ If, for example, | |||
1468 | .Cm ServerAliveCountMax | 1468 | .Cm ServerAliveCountMax |
1469 | is left at the default, if the server becomes unresponsive, | 1469 | is left at the default, if the server becomes unresponsive, |
1470 | ssh will disconnect after approximately 45 seconds. | 1470 | ssh will disconnect after approximately 45 seconds. |
1471 | This option applies to protocol version 2 only. | 1471 | This option applies to protocol version 2 only; in protocol version |
1472 | 1 there is no mechanism to request a response from the server to the | ||
1473 | server alive messages, so disconnection is the responsibility of the TCP | ||
1474 | stack. | ||
1472 | .It Cm ServerAliveInterval | 1475 | .It Cm ServerAliveInterval |
1473 | Sets a timeout interval in seconds after which if no data has been received | 1476 | Sets a timeout interval in seconds after which if no data has been received |
1474 | from the server, | 1477 | from the server, |