diff --git a/src/cli.c b/src/cli.c index e60113d92..bbd11c1d1 100644 --- a/src/cli.c +++ b/src/cli.c @@ -3487,7 +3487,7 @@ err: } /* - * Creates a sockpair, a "master-socket" bind conf and a listener. Assigns + * Creates a "master-socket" bind conf and a listener. Assigns * this new listener to the one "end" of the given process sockpair in * order to have a new master CLI listening socket for this process. */ @@ -3498,12 +3498,6 @@ int mworker_cli_global_proxy_new_listener(struct mworker_proc *proc) char *path = NULL; char *err = NULL; - /* master pipe to ensure the master is still alive */ - if (socketpair(AF_UNIX, SOCK_STREAM, 0, proc->ipc_fd) < 0) { - ha_alert("Cannot create worker socketpair.\n"); - return -1; - } - /* XXX: we might want to use a separate frontend at some point */ if (!global.cli_fe) { if ((global.cli_fe = cli_alloc_fe("GLOBAL", "master-socket", 0)) == NULL) { diff --git a/src/haproxy.c b/src/haproxy.c index 62e173292..e20f36052 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -109,6 +109,7 @@ #include #include #include +#include #include #include #include @@ -2096,8 +2097,18 @@ static void init(int argc, char **argv) } tmproc->options |= PROC_O_TYPE_WORKER; /* worker */ - if (mworker_cli_global_proxy_new_listener(tmproc) < 0) + /* create a sockpair to copy it via fork(), thus it will be in + * master and in worker processes + */ + if (socketpair(AF_UNIX, SOCK_STREAM, 0, tmproc->ipc_fd) < 0) { + ha_alert("Cannot create worker master CLI socketpair.\n"); exit(EXIT_FAILURE); + } + if (mworker_cli_global_proxy_new_listener(tmproc) < 0) { + close(tmproc->ipc_fd[0]); + close(tmproc->ipc_fd[1]); + exit(EXIT_FAILURE); + } LIST_APPEND(&proc_list, &tmproc->list); }