BUG/MEDIUM: mworker: increase maxsock with each new worker

In ticket #2184, HAProxy is crashing in a BUG_ON() after a lot of reload
when the previous processes did not exit.

Each worker has a socketpair which is a FD in the master, when reloading
this FD still exists until the process leaves. But the global.maxconn
value is not incremented for each of these FD. So when there is too much
workers and the number of FD reaches maxsock, the next FD inserted in
the poller will crash the process.

This patch fixes the issue by increasing the maxsock for each remaining
worker.

Must be backported in every maintained version.
This commit is contained in:
William Lallemand 2023-06-19 17:12:58 +02:00
parent 98b55d1260
commit e6051a04ef

View File

@ -218,8 +218,12 @@ int mworker_env_to_proc_list()
} else if (strncmp(subtoken, "fd=", 3) == 0) {
child->ipc_fd[0] = atoi(subtoken+3);
if (child->ipc_fd[0] > -1)
global.maxsock++;
} else if (strncmp(subtoken, "cfd=", 4) == 0) {
child->ipc_fd[1] = atoi(subtoken+4);
if (child->ipc_fd[1] > -1)
global.maxsock++;
} else if (strncmp(subtoken, "pid=", 4) == 0) {
child->pid = atoi(subtoken+4);
} else if (strncmp(subtoken, "reloads=", 8) == 0) {