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.
* 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 */