From bb95317774023dcbfaaeaeb635942ec15f17c3d8 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Wed, 13 Apr 2016 02:39:14 -0400 Subject: [PATCH] [core] setrlimit max-fds <= rlim_max for non-root (fixes #2723) x-ref: "setrlimit can increase RLIMIT_NOFILE up to rlim_max for non-root" https://redmine.lighttpd.net/issues/2723 --- NEWS | 1 + src/server.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index b197082b..6a934ded 100644 --- a/NEWS +++ b/NEWS @@ -73,6 +73,7 @@ NEWS * [mod_status] table w/ count of con states (fixes #2427) * [mod_dirlisting] class for dir (fixes #2304) * [core] define __STDC_WANT_LIB_EXT1__ (fixes #2722) + * [core] setrlimit max-fds <= rlim_max for non-root (fixes #2723) - 1.4.39 - 2016-01-02 * [core] fix memset_s call (fixes #2698) diff --git a/src/server.c b/src/server.c index 61d850c3..7aacf2e0 100644 --- a/src/server.c +++ b/src/server.c @@ -954,9 +954,9 @@ int main (int argc, char **argv) { } /** - * we are not root can can't increase the fd-limit, but we can reduce it + * we are not root can can't increase the fd-limit above rlim_max, but we can reduce it */ - if (srv->srvconf.max_fds && srv->srvconf.max_fds < rlim.rlim_cur) { + if (srv->srvconf.max_fds && srv->srvconf.max_fds <= rlim.rlim_max) { /* set rlimits */ rlim.rlim_cur = srv->srvconf.max_fds;