summaryrefslogtreecommitdiff
path: root/serverloop.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2012-04-22 11:21:10 +1000
committerDamien Miller <djm@mindrot.org>2012-04-22 11:21:10 +1000
commita6508753db3c49910068d8fc324bd284d72ff153 (patch)
treede5d49ef31b5ba61e9086316baf0bd2afb78fd1b /serverloop.c
parentc6081482b2b72caccce938c100c1b55f7b5e30fe (diff)
- 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@
Diffstat (limited to 'serverloop.c')
-rw-r--r--serverloop.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/serverloop.c b/serverloop.c
index 19b84ff27..50be16b7c 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: serverloop.c,v 1.160 2011/05/15 08:09:01 djm Exp $ */ 1/* $OpenBSD: serverloop.c,v 1.161 2012/04/11 13:16:19 djm 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
@@ -281,9 +281,18 @@ wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp,
281{ 281{
282 struct timeval tv, *tvp; 282 struct timeval tv, *tvp;
283 int ret; 283 int ret;
284 time_t minwait_secs;
284 int client_alive_scheduled = 0; 285 int client_alive_scheduled = 0;
285 int program_alive_scheduled = 0; 286 int program_alive_scheduled = 0;
286 287
288 /* Allocate and update select() masks for channel descriptors. */
289 channel_prepare_select(readsetp, writesetp, maxfdp, nallocp,
290 &minwait_secs, 0);
291
292 if (minwait_secs != 0)
293 max_time_milliseconds = MIN(max_time_milliseconds,
294 (u_int)minwait_secs * 1000);
295
287 /* 296 /*
288 * if using client_alive, set the max timeout accordingly, 297 * if using client_alive, set the max timeout accordingly,
289 * and indicate that this particular timeout was for client 298 * 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,
298 max_time_milliseconds = options.client_alive_interval * 1000; 307 max_time_milliseconds = options.client_alive_interval * 1000;
299 } 308 }
300 309
301 /* Allocate and update select() masks for channel descriptors. */
302 channel_prepare_select(readsetp, writesetp, maxfdp, nallocp, 0);
303
304 if (compat20) { 310 if (compat20) {
305#if 0 311#if 0
306 /* wrong: bad condition XXX */ 312 /* wrong: bad condition XXX */