MINOR: sock: check configured limits at the sock layer, not the listener's

listener_accept() used to continue to enforce the FD limits relative to
global.maxsock by itself while it's the last FD-specific test in the
whole file. This test has nothing to do there, it ought to be placed in
sock_accept_conn() which is the one in charge of FD allocation and tests.
Similar tests are already located there by the way. The only tiny
difference is that listener_accept() used to pause for one second when
this limit was reached, while other similar conditions were pausing only
100ms, so now the same 100ms will apply. But that's not important and
could even be considered as an improvement.
This commit is contained in:
Willy Tarreau 2022-04-11 15:01:37 +02:00
parent 6ea6ed7418
commit e4d09cedb6
2 changed files with 8 additions and 10 deletions

View File

@ -965,16 +965,6 @@ void listener_accept(struct listener *l)
_HA_ATOMIC_INC(&activity[tid].accepted);
if (unlikely(cli_conn->handle.fd >= global.maxsock)) {
send_log(p, LOG_EMERG,
"Proxy %s reached the configured maximum connection limit. Please check the global 'maxconn' value.\n",
p->id);
close(cli_conn->handle.fd);
conn_free(cli_conn);
expire = tick_add(now_ms, 1000); /* try again in 1 second */
goto limit_global;
}
/* past this point, l->accept() will automatically decrement
* l->nbconn, feconn and actconn once done. Setting next_*conn=0
* allows the error path not to rollback on nbconn. It's more

View File

@ -103,6 +103,14 @@ struct connection *sock_accept_conn(struct listener *l, int *status)
}
if (likely(cfd != -1)) {
if (unlikely(cfd >= global.maxsock)) {
close(cfd);
send_log(p, LOG_EMERG,
"Proxy %s reached the configured maximum connection limit. Please check the global 'maxconn' value.\n",
p->id);
goto fail_conn;
}
/* Perfect, the connection was accepted */
conn = conn_new(&l->obj_type);
if (!conn)