[core] free fdwaitqueue list when empty

fdwaitqueue is typically unused except in severe overload conditions,
so free up the list storage as soon as it is empty
master
Glenn Strauss 1 year ago
parent 311d4b0ef4
commit c69450ec04
  1. 10
      src/server.c

@ -1065,8 +1065,14 @@ static void server_process_fdwaitqueue (server *srv) {
if (i == fdwaitqueue->used) break;
connection_state_machine(fdwaitqueue->ptr[i++]);
}
if (i > 0 && 0 != (fdwaitqueue->used -= i)) {
memmove(fdwaitqueue->ptr, fdwaitqueue->ptr+i, fdwaitqueue->used * sizeof(*(fdwaitqueue->ptr)));
if (0 == (fdwaitqueue->used -= i)) {
free(fdwaitqueue->ptr);
fdwaitqueue->ptr = NULL;
fdwaitqueue->size = 0;
}
else if (i > 0) {
memmove(fdwaitqueue->ptr, fdwaitqueue->ptr+i,
fdwaitqueue->used * sizeof(*(fdwaitqueue->ptr)));
}
}

Loading…
Cancel
Save