summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2014-02-09 16:09:51 +0000
committerColin Watson <cjwatson@debian.org>2015-08-19 17:09:56 +0100
commitb3d7661669a0f5255ede81f82c25951aeba9576c (patch)
tree95938dcdf4e69dd37b97796d89184c9ba33db805
parentdd02db02d322c9db67d42fe491727854f951c828 (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.c25
-rw-r--r--ssh_config.55
2 files changed, 19 insertions, 11 deletions
diff --git a/clientloop.c b/clientloop.c
index 77d549822..964353dc3 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -577,16 +577,21 @@ client_global_request_reply(int type, u_int32_t seq, void *ctxt)
577static void 577static void
578server_alive_check(void) 578server_alive_check(void)
579{ 579{
580 if (packet_inc_alive_timeouts() > options.server_alive_count_max) { 580 if (compat20) {
581 logit("Timeout, server %s not responding.", host); 581 if (packet_inc_alive_timeouts() > options.server_alive_count_max) {
582 cleanup_exit(255); 582 logit("Timeout, server %s not responding.", host);
583 cleanup_exit(255);
584 }
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 } else {
592 packet_send_ignore(0);
593 packet_send();
583 } 594 }
584 packet_start(SSH2_MSG_GLOBAL_REQUEST);
585 packet_put_cstring("keepalive@openssh.com");
586 packet_put_char(1); /* boolean: want reply */
587 packet_send();
588 /* Insert an empty placeholder to maintain ordering */
589 client_register_global_confirm(NULL, NULL);
590} 595}
591 596
592/* 597/*
@@ -648,7 +653,7 @@ client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp,
648 */ 653 */
649 654
650 timeout_secs = INT_MAX; /* we use INT_MAX to mean no timeout */ 655 timeout_secs = INT_MAX; /* we use INT_MAX to mean no timeout */
651 if (options.server_alive_interval > 0 && compat20) { 656 if (options.server_alive_interval > 0) {
652 timeout_secs = options.server_alive_interval; 657 timeout_secs = options.server_alive_interval;
653 server_alive_time = now + options.server_alive_interval; 658 server_alive_time = now + options.server_alive_interval;
654 } 659 }
diff --git a/ssh_config.5 b/ssh_config.5
index b84026195..f7510b6ce 100644
--- a/ssh_config.5
+++ b/ssh_config.5
@@ -1414,7 +1414,10 @@ If, for example,
1414.Cm ServerAliveCountMax 1414.Cm ServerAliveCountMax
1415is left at the default, if the server becomes unresponsive, 1415is left at the default, if the server becomes unresponsive,
1416ssh will disconnect after approximately 45 seconds. 1416ssh will disconnect after approximately 45 seconds.
1417This option applies to protocol version 2 only. 1417This option applies to protocol version 2 only; in protocol version
14181 there is no mechanism to request a response from the server to the
1419server alive messages, so disconnection is the responsibility of the TCP
1420stack.
1418.It Cm ServerAliveInterval 1421.It Cm ServerAliveInterval
1419Sets a timeout interval in seconds after which if no data has been received 1422Sets a timeout interval in seconds after which if no data has been received
1420from the server, 1423from the server,