}
/*
- * 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 <proc> sockpair in
* order to have a new master CLI listening socket for this process.
*/
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) {
#include <haproxy/peers.h>
#include <haproxy/pool.h>
#include <haproxy/protocol.h>
+#include <haproxy/proto_sockpair.h>
#include <haproxy/proto_tcp.h>
#include <haproxy/proxy.h>
#include <haproxy/regex.h>
}
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);
}