From a8c9b38118b9c963dad72f577f74a729a03d6e5d Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Mon, 26 Jul 2021 01:26:47 -0400 Subject: [PATCH] [core] adjust srv->srvconf.max_conns at startup adjust srv->srvconf.max_conns at startup, if adjustment needed --- src/connections.c | 6 +++--- src/mod_dirlisting.c | 2 +- src/server.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/connections.c b/src/connections.c index 1176d7f9..6cce7d5c 100644 --- a/src/connections.c +++ b/src/connections.c @@ -50,9 +50,9 @@ static void connection_reset(connection *con); __attribute_cold__ __attribute_noinline__ static void connections_extend(server * const srv, connections * const conns) { - const uint32_t n = (srv->max_conns >= 128 && conns->size >= 16) - ? (0 != conns->size) ? 128 : 128 - 16 - : (srv->max_conns > 16) ? 16 : srv->max_conns; + const uint32_t n = (srv->srvconf.max_conns >= 128 && conns->size >= 16) + ? (0 != conns->size) ? 128 : 128 - 16 + : (srv->srvconf.max_conns > 16) ? 16 : srv->srvconf.max_conns; if (conns->size < 128 && srv->srvconf.h2proto) request_pool_extend(srv, n * 8); diff --git a/src/mod_dirlisting.c b/src/mod_dirlisting.c index e5134992..e7208af1 100644 --- a/src/mod_dirlisting.c +++ b/src/mod_dirlisting.c @@ -473,7 +473,7 @@ SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) { } } - dirlist_max_in_progress = srv->max_conns >> 4; + dirlist_max_in_progress = srv->srvconf.max_conns >> 4; if (0 == dirlist_max_in_progress) dirlist_max_in_progress = 1; p->defaults.dir_listing = 0; diff --git a/src/server.c b/src/server.c index 4c791d25..d0f5e29a 100644 --- a/src/server.c +++ b/src/server.c @@ -1758,13 +1758,13 @@ static int server_main_setup (server * const srv, int argc, char **argv) { log_error(srv->errh, __FILE__, __LINE__, "can't have more connections than fds/2: %hu %d", srv->srvconf.max_conns, srv->max_fds); - srv->max_conns = srv->max_fds/2; + srv->max_conns = srv->srvconf.max_conns = srv->max_fds/2; } else if (srv->srvconf.max_conns) { /* otherwise respect the wishes of the user */ srv->max_conns = srv->srvconf.max_conns; } else { /* or use the default: we really don't want to hit max-fds */ - srv->max_conns = srv->max_fds/3; + srv->max_conns = srv->srvconf.max_conns = srv->max_fds/3; } /* libev backend overwrites our SIGCHLD handler and calls waitpid on SIGCHLD; we want our own SIGCHLD handling. */