summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2021-12-18 19:57:40 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2021-12-18 19:57:40 -0500
commit3551dd74a53f82aab1aae7111c334cdd11f174f0 (patch)
treeea1d65ef4419a94a1e407587825cd391eb08a5e1 /src
parentb6c70a1e723fe8b627a28b326551dd6e3299aecd (diff)
downloadlighttpd-git-3551dd74a53f82aab1aae7111c334cdd11f174f0.tar.gz
[core] use lower limit for max-fds if !setrlimit
use lower limit for server.max-fds if setrlimit() fails
Diffstat (limited to 'src')
-rw-r--r--src/server.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/server.c b/src/server.c
index beca364a..3ec94e2d 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1352,6 +1352,7 @@ static int server_main_setup (server * const srv, int argc, char **argv) {
&& (i_am_root || srv->srvconf.max_fds <= rlim.rlim_max)) {
/* set rlimits */
+ rlim_t rlim_cur = rlim.rlim_cur;
rlim.rlim_cur = srv->srvconf.max_fds;
if (i_am_root) rlim.rlim_max = srv->srvconf.max_fds;
@@ -1359,6 +1360,8 @@ static int server_main_setup (server * const srv, int argc, char **argv) {
log_perror(srv->errh, __FILE__, __LINE__, "setrlimit()");
log_error(srv->errh, __FILE__, __LINE__, "setrlimit() may need root to run once: setsebool -P httpd_setrlimit on");
use_rlimit = 0;
+ if (srv->srvconf.max_fds > rlim_cur)
+ srv->srvconf.max_fds = rlim_cur;
}
}