From a6508753db3c49910068d8fc324bd284d72ff153 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Sun, 22 Apr 2012 11:21:10 +1000 Subject: - djm@cvs.openbsd.org 2012/04/11 13:16:19 [channels.c channels.h clientloop.c serverloop.c] don't spin in accept() when out of fds (ENFILE/ENFILE) - back off for a while; ok deraadt@ markus@ --- serverloop.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'serverloop.c') diff --git a/serverloop.c b/serverloop.c index 19b84ff27..50be16b7c 100644 --- a/serverloop.c +++ b/serverloop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: serverloop.c,v 1.160 2011/05/15 08:09:01 djm Exp $ */ +/* $OpenBSD: serverloop.c,v 1.161 2012/04/11 13:16:19 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -281,9 +281,18 @@ wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp, { struct timeval tv, *tvp; int ret; + time_t minwait_secs; int client_alive_scheduled = 0; int program_alive_scheduled = 0; + /* Allocate and update select() masks for channel descriptors. */ + channel_prepare_select(readsetp, writesetp, maxfdp, nallocp, + &minwait_secs, 0); + + if (minwait_secs != 0) + max_time_milliseconds = MIN(max_time_milliseconds, + (u_int)minwait_secs * 1000); + /* * if using client_alive, set the max timeout accordingly, * and indicate that this particular timeout was for client @@ -298,9 +307,6 @@ wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp, max_time_milliseconds = options.client_alive_interval * 1000; } - /* Allocate and update select() masks for channel descriptors. */ - channel_prepare_select(readsetp, writesetp, maxfdp, nallocp, 0); - if (compat20) { #if 0 /* wrong: bad condition XXX */ -- cgit v1.2.3 From 6c6da33d31c898781ffb45c5d10502b0f84dd4a4 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Wed, 20 Jun 2012 22:31:26 +1000 Subject: - djm@cvs.openbsd.org 2012/06/20 04:42:58 [clientloop.c serverloop.c] initialise accept() backoff timer to avoid EINVAL from select(2) in rekeying --- ChangeLog | 4 ++++ clientloop.c | 4 ++-- serverloop.c | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'serverloop.c') diff --git a/ChangeLog b/ChangeLog index d1ad692eb..6f9031ff9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -50,6 +50,10 @@ - jmc@cvs.openbsd.org 2012/06/19 21:35:54 [sshd_config.5] tweak previous; ok markus + - djm@cvs.openbsd.org 2012/06/20 04:42:58 + [clientloop.c serverloop.c] + initialise accept() backoff timer to avoid EINVAL from select(2) in + rekeying 20120519 - (dtucker) [configure.ac] bz#2010: fix non-portable shell construct. Patch diff --git a/clientloop.c b/clientloop.c index 58357cf39..1c1a77088 100644 --- a/clientloop.c +++ b/clientloop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clientloop.c,v 1.239 2012/04/11 13:16:19 djm Exp $ */ +/* $OpenBSD: clientloop.c,v 1.240 2012/06/20 04:42:58 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -583,7 +583,7 @@ client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, { struct timeval tv, *tvp; int timeout_secs; - time_t minwait_secs; + time_t minwait_secs = 0; int ret; /* Add any selections by the channel mechanism. */ diff --git a/serverloop.c b/serverloop.c index 50be16b7c..741c5befb 100644 --- a/serverloop.c +++ b/serverloop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: serverloop.c,v 1.161 2012/04/11 13:16:19 djm Exp $ */ +/* $OpenBSD: serverloop.c,v 1.162 2012/06/20 04:42:58 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -281,7 +281,7 @@ wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp, { struct timeval tv, *tvp; int ret; - time_t minwait_secs; + time_t minwait_secs = 0; int client_alive_scheduled = 0; int program_alive_scheduled = 0; -- cgit v1.2.3