Skip to content

Commit 745a4c5

Browse files
committed
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.
1 parent 2f04ebe commit 745a4c5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/mworker.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -908,10 +908,11 @@ void mworker_create_master_cli(void)
908908
* Both FDs will be kept in the master. The sockets are
909909
* created only if they weren't inherited.
910910
*/
911-
if ((proc_self->ipc_fd[1] == -1) &&
912-
socketpair(AF_UNIX, SOCK_STREAM, 0, proc_self->ipc_fd) < 0) {
913-
ha_alert("Can't create the mcli_reload socketpair.\n");
914-
exit(EXIT_FAILURE);
911+
if (proc_self->ipc_fd[1] == -1) {
912+
if (socketpair(AF_UNIX, SOCK_STREAM, 0, proc_self->ipc_fd) < 0) {
913+
ha_alert("Can't create the mcli_reload socketpair.\n");
914+
exit(EXIT_FAILURE);
915+
}
915916
}
916917

917918
/* Create the mcli_reload listener from the proc_self struct */

0 commit comments

Comments
 (0)