Browse Source

[core] adjust srv->srvconf.max_conns at startup

adjust srv->srvconf.max_conns at startup, if adjustment needed
master
Glenn Strauss 4 months ago
parent
commit
a8c9b38118
  1. 6
      src/connections.c
  2. 2
      src/mod_dirlisting.c
  3. 4
      src/server.c

6
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);

2
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;

4
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. */

Loading…
Cancel
Save