Browse Source

[core] reduce con allocation for small max_conns

reduce con allocation for small server.max_conns
(do not allocate structures that will never be used)
personal/stbuehler/mod-csrf
Glenn Strauss 5 years ago
parent
commit
970f337c29
  1. 4
      src/connections.c

4
src/connections.c

@ -43,7 +43,7 @@ static connection *connections_get_new_connection(server *srv) {
size_t i;
if (conns->size == 0) {
conns->size = 128;
conns->size = srv->max_conns >= 128 ? 128 : srv->max_conns > 16 ? 16 : srv->max_conns;
conns->ptr = NULL;
conns->ptr = malloc(sizeof(*conns->ptr) * conns->size);
force_assert(NULL != conns->ptr);
@ -51,7 +51,7 @@ static connection *connections_get_new_connection(server *srv) {
conns->ptr[i] = connection_init(srv);
}
} else if (conns->size == conns->used) {
conns->size += 128;
conns->size += srv->max_conns >= 128 ? 128 : 16;
conns->ptr = realloc(conns->ptr, sizeof(*conns->ptr) * conns->size);
force_assert(NULL != conns->ptr);

Loading…
Cancel
Save