From: Valentine Krasnobaeva Date: Sat, 26 Oct 2024 13:03:19 +0000 (+0200) Subject: CLEANUP: mworker: make mworker_create_master_cli more readable X-Git-Tag: v3.1-dev11~45 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=745a4c5e934929e623e7d76d2b4d0d895f043b25;p=thirdparty%2Fhaproxy.git CLEANUP: mworker: make mworker_create_master_cli more readable Using nested 'if' operator, while checking if we will need to allocate again the "reload" sockpair, does not degrade performance, as mworker_create_master_cli is a startup routine. This nested 'if' (we check one condition in each operator) makes more visible the fact, that the "reload" sockpair is allocated only once, when the master process starts and it does not re-allocated again (hence, its FDs are not closed) during reloads. This way of checking multiple conditions here makes more easy to spot this fact, while analysing the code in order to investigate FD leaks between master and worker. --- diff --git a/src/mworker.c b/src/mworker.c index 10f0cb1837..b8daf2935b 100644 --- a/src/mworker.c +++ b/src/mworker.c @@ -908,10 +908,11 @@ void mworker_create_master_cli(void) * Both FDs will be kept in the master. The sockets are * created only if they weren't inherited. */ - if ((proc_self->ipc_fd[1] == -1) && - socketpair(AF_UNIX, SOCK_STREAM, 0, proc_self->ipc_fd) < 0) { - ha_alert("Can't create the mcli_reload socketpair.\n"); - exit(EXIT_FAILURE); + if (proc_self->ipc_fd[1] == -1) { + if (socketpair(AF_UNIX, SOCK_STREAM, 0, proc_self->ipc_fd) < 0) { + ha_alert("Can't create the mcli_reload socketpair.\n"); + exit(EXIT_FAILURE); + } } /* Create the mcli_reload listener from the proc_self struct */