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 16:33:31 +0100
commit396f7d932b391fc92ac7ccdf8813f49564e2bbab (patch)
tree24b103b6f22e4e4f691fe5cff55f4be07de9b92b
parentd027dea6b4b659a7ad537e452db563763302eabd (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 7df941375..156a196dc 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -564,16 +564,21 @@ client_global_request_reply(int type, u_int32_t seq, void *ctxt)
564static void 564static void
565server_alive_check(void) 565server_alive_check(void)
566{ 566{
567 if (packet_inc_alive_timeouts() > options.server_alive_count_max) { 567 if (compat20) {
568 logit("Timeout, server %s not responding.", host); 568 if (packet_inc_alive_timeouts() > options.server_alive_count_max) {
569 cleanup_exit(255); 569 logit("Timeout, server %s not responding.", host);
570 cleanup_exit(255);
571 }
572 packet_start(SSH2_MSG_GLOBAL_REQUEST);
573 packet_put_cstring("keepalive@openssh.com");
574 packet_put_char(1); /* boolean: want reply */
575 packet_send();
576 /* Insert an empty placeholder to maintain ordering */
577 client_register_global_confirm(NULL, NULL);
578 } else {
579 packet_send_ignore(0);
580 packet_send();
570 } 581 }
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} 582}
578 583
579/* 584/*
@@ -635,7 +640,7 @@ client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp,
635 */ 640 */
636 641
637 timeout_secs = INT_MAX; /* we use INT_MAX to mean no timeout */ 642 timeout_secs = INT_MAX; /* we use INT_MAX to mean no timeout */
638 if (options.server_alive_interval > 0 && compat20) { 643 if (options.server_alive_interval > 0) {
639 timeout_secs = options.server_alive_interval; 644 timeout_secs = options.server_alive_interval;
640 server_alive_time = now + options.server_alive_interval; 645 server_alive_time = now + options.server_alive_interval;
641 } 646 }
diff --git a/ssh_config.5 b/ssh_config.5
index 447617178..dd35dd8d1 100644
--- a/ssh_config.5
+++ b/ssh_config.5
@@ -1409,7 +1409,10 @@ If, for example,
1409.Cm ServerAliveCountMax 1409.Cm ServerAliveCountMax
1410is left at the default, if the server becomes unresponsive, 1410is left at the default, if the server becomes unresponsive,
1411ssh will disconnect after approximately 45 seconds. 1411ssh will disconnect after approximately 45 seconds.
1412This option applies to protocol version 2 only. 1412This option applies to protocol version 2 only; in protocol version
14131 there is no mechanism to request a response from the server to the
1414server alive messages, so disconnection is the responsibility of the TCP
1415stack.
1413.It Cm ServerAliveInterval 1416.It Cm ServerAliveInterval
1414Sets a timeout interval in seconds after which if no data has been received 1417Sets a timeout interval in seconds after which if no data has been received
1415from the server, 1418from the server,