mirror of
git://anongit.mindrot.org/openssh.git
synced 2025-01-11 12:09:32 +00:00
upstream: Reset last-seen time when sending a keepalive. Prevents
sending two keepalives successively and prematurely terminating connection when ClientAliveCount=1. While there, collapse two similar tests into one. ok markus@ OpenBSD-Commit-ID: 043670d201dfe222537a2a4bed16ce1087de5ddd
This commit is contained in:
parent
c13b74530f
commit
ab5fee8eb6
15
serverloop.c
15
serverloop.c
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: serverloop.c,v 1.213 2019/01/19 22:30:52 djm Exp $ */
|
/* $OpenBSD: serverloop.c,v 1.214 2019/03/06 21:06:59 dtucker Exp $ */
|
||||||
/*
|
/*
|
||||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||||
@ -225,6 +225,7 @@ wait_until_can_do_something(struct ssh *ssh,
|
|||||||
int ret;
|
int ret;
|
||||||
time_t minwait_secs = 0;
|
time_t minwait_secs = 0;
|
||||||
int client_alive_scheduled = 0;
|
int client_alive_scheduled = 0;
|
||||||
|
/* time we last heard from the client OR sent a keepalive */
|
||||||
static time_t last_client_time;
|
static time_t last_client_time;
|
||||||
|
|
||||||
/* Allocate and update select() masks for channel descriptors. */
|
/* Allocate and update select() masks for channel descriptors. */
|
||||||
@ -293,13 +294,15 @@ wait_until_can_do_something(struct ssh *ssh,
|
|||||||
} else if (client_alive_scheduled) {
|
} else if (client_alive_scheduled) {
|
||||||
time_t now = monotime();
|
time_t now = monotime();
|
||||||
|
|
||||||
if (ret == 0) { /* timeout */
|
/*
|
||||||
|
* If the select timed out, or returned for some other reason
|
||||||
|
* but we haven't heard from the client in time, send keepalive.
|
||||||
|
*/
|
||||||
|
if (ret == 0 || (last_client_time != 0 && last_client_time +
|
||||||
|
options.client_alive_interval <= now)) {
|
||||||
client_alive_check(ssh);
|
client_alive_check(ssh);
|
||||||
} else if (FD_ISSET(connection_in, *readsetp)) {
|
|
||||||
last_client_time = now;
|
last_client_time = now;
|
||||||
} else if (last_client_time != 0 && last_client_time +
|
} else if (FD_ISSET(connection_in, *readsetp)) {
|
||||||
options.client_alive_interval <= now) {
|
|
||||||
client_alive_check(ssh);
|
|
||||||
last_client_time = now;
|
last_client_time = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user