diff options
-rw-r--r-- | serverloop.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/serverloop.c b/serverloop.c index 9602e050d..f86f832b6 100644 --- a/serverloop.c +++ b/serverloop.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: serverloop.c,v 1.213 2019/01/19 22:30:52 djm Exp $ */ | 1 | /* $OpenBSD: serverloop.c,v 1.214 2019/03/06 21:06:59 dtucker Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -225,6 +225,7 @@ wait_until_can_do_something(struct ssh *ssh, | |||
225 | int ret; | 225 | int ret; |
226 | time_t minwait_secs = 0; | 226 | time_t minwait_secs = 0; |
227 | int client_alive_scheduled = 0; | 227 | int client_alive_scheduled = 0; |
228 | /* time we last heard from the client OR sent a keepalive */ | ||
228 | static time_t last_client_time; | 229 | static time_t last_client_time; |
229 | 230 | ||
230 | /* Allocate and update select() masks for channel descriptors. */ | 231 | /* Allocate and update select() masks for channel descriptors. */ |
@@ -293,13 +294,15 @@ wait_until_can_do_something(struct ssh *ssh, | |||
293 | } else if (client_alive_scheduled) { | 294 | } else if (client_alive_scheduled) { |
294 | time_t now = monotime(); | 295 | time_t now = monotime(); |
295 | 296 | ||
296 | if (ret == 0) { /* timeout */ | 297 | /* |
298 | * If the select timed out, or returned for some other reason | ||
299 | * but we haven't heard from the client in time, send keepalive. | ||
300 | */ | ||
301 | if (ret == 0 || (last_client_time != 0 && last_client_time + | ||
302 | options.client_alive_interval <= now)) { | ||
297 | client_alive_check(ssh); | 303 | client_alive_check(ssh); |
298 | } else if (FD_ISSET(connection_in, *readsetp)) { | ||
299 | last_client_time = now; | 304 | last_client_time = now; |
300 | } else if (last_client_time != 0 && last_client_time + | 305 | } else if (FD_ISSET(connection_in, *readsetp)) { |
301 | options.client_alive_interval <= now) { | ||
302 | client_alive_check(ssh); | ||
303 | last_client_time = now; | 306 | last_client_time = now; |
304 | } | 307 | } |
305 | } | 308 | } |