summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2014-02-09 16:09:51 +0000
committerColin Watson <cjwatson@debian.org>2014-02-10 02:40:15 +0000
commit9f42d3b964854aecfed2fff64ac375c0c4805fa5 (patch)
tree1569184b1a3b2b4df2596537defa65118b542fb9
parent889e217b88a7848e6c997f7f87d07b9d1a35fb49 (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 6d02b0b3a..37b3a040d 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -563,16 +563,21 @@ client_global_request_reply(int type, u_int32_t seq, void *ctxt)
563static void 563static void
564server_alive_check(void) 564server_alive_check(void)
565{ 565{
566 if (packet_inc_alive_timeouts() > options.server_alive_count_max) { 566 if (compat20) {
567 logit("Timeout, server %s not responding.", host); 567 if (packet_inc_alive_timeouts() > options.server_alive_count_max) {
568 cleanup_exit(255); 568 logit("Timeout, server %s not responding.", host);
569 cleanup_exit(255);
570 }
571 packet_start(SSH2_MSG_GLOBAL_REQUEST);
572 packet_put_cstring("keepalive@openssh.com");
573 packet_put_char(1); /* boolean: want reply */
574 packet_send();
575 /* Insert an empty placeholder to maintain ordering */
576 client_register_global_confirm(NULL, NULL);
577 } else {
578 packet_send_ignore(0);
579 packet_send();
569 } 580 }
570 packet_start(SSH2_MSG_GLOBAL_REQUEST);
571 packet_put_cstring("keepalive@openssh.com");
572 packet_put_char(1); /* boolean: want reply */
573 packet_send();
574 /* Insert an empty placeholder to maintain ordering */
575 client_register_global_confirm(NULL, NULL);
576} 581}
577 582
578/* 583/*
@@ -634,7 +639,7 @@ client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp,
634 */ 639 */
635 640
636 timeout_secs = INT_MAX; /* we use INT_MAX to mean no timeout */ 641 timeout_secs = INT_MAX; /* we use INT_MAX to mean no timeout */
637 if (options.server_alive_interval > 0 && compat20) { 642 if (options.server_alive_interval > 0) {
638 timeout_secs = options.server_alive_interval; 643 timeout_secs = options.server_alive_interval;
639 server_alive_time = now + options.server_alive_interval; 644 server_alive_time = now + options.server_alive_interval;
640 } 645 }
diff --git a/ssh_config.5 b/ssh_config.5
index 49505ae9c..617a312d0 100644
--- a/ssh_config.5
+++ b/ssh_config.5
@@ -1288,7 +1288,10 @@ If, for example,
1288.Cm ServerAliveCountMax 1288.Cm ServerAliveCountMax
1289is left at the default, if the server becomes unresponsive, 1289is left at the default, if the server becomes unresponsive,
1290ssh will disconnect after approximately 45 seconds. 1290ssh will disconnect after approximately 45 seconds.
1291This option applies to protocol version 2 only. 1291This option applies to protocol version 2 only; in protocol version
12921 there is no mechanism to request a response from the server to the
1293server alive messages, so disconnection is the responsibility of the TCP
1294stack.
1292.It Cm ServerAliveInterval 1295.It Cm ServerAliveInterval
1293Sets a timeout interval in seconds after which if no data has been received 1296Sets a timeout interval in seconds after which if no data has been received
1294from the server, 1297from the server,