summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2014-02-09 16:09:51 +0000
committerColin Watson <cjwatson@debian.org>2015-09-17 13:52:39 +0100
commit634f3188e7f3c104cc7b13a078059f15f3f4a68a (patch)
tree6af88cc76dc4181cd034b0b2f3114ffe6e359234
parent654750762053d631bd1e1176c230eaeaad9b4250 (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 59ce400dc..e60a5b4ea 100644
--- a/ssh_config.5
+++ b/ssh_config.5
@@ -1416,7 +1416,10 @@ If, for example,
1416.Cm ServerAliveCountMax 1416.Cm ServerAliveCountMax
1417is left at the default, if the server becomes unresponsive, 1417is left at the default, if the server becomes unresponsive,
1418ssh will disconnect after approximately 45 seconds. 1418ssh will disconnect after approximately 45 seconds.
1419This option applies to protocol version 2 only. 1419This option applies to protocol version 2 only; in protocol version
14201 there is no mechanism to request a response from the server to the
1421server alive messages, so disconnection is the responsibility of the TCP
1422stack.
1420.It Cm ServerAliveInterval 1423.It Cm ServerAliveInterval
1421Sets a timeout interval in seconds after which if no data has been received 1424Sets a timeout interval in seconds after which if no data has been received
1422from the server, 1425from the server,