BUG/MEDIUM: mworker: don't register mworker_accept_wrapper() when master FD is wrong

This patch handles the case where the fd could be -1 when proc_self was
lost for some reason (environment variable corrupted or upgrade from < 1.9).

This could result in a out of bound array access fdtab[-1] and would crash.

Must be backported in every maintained versions.

(cherry picked from commit cc5b9fa593e139fa330f8c7161ff7514315f2837)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
(cherry picked from commit 49650955ae6a581226aeb7186650f4a45643a7ce)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
(cherry picked from commit 2f874eaab7c4b4dbe3b485d05f3e46887d72c7c1)
[wla: context change, s/fd_set_nonblock/fcntl/]
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
(cherry picked from commit 67ac05465a32dbf82fc750b8bb722f3ef87d029b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/mworker.c b/src/mworker.c
index a77c0a1..48a2c5b 100644
--- a/src/mworker.c
+++ b/src/mworker.c
@@ -406,6 +406,9 @@
 	if (tid != 0)
 		return 1;
 
+	if (proc_self->ipc_fd[1] < 0) /* proc_self was incomplete and we can't find the socketpair */
+		return 1;
+
 	fcntl(proc_self->ipc_fd[1], F_SETFL, O_NONBLOCK);
 	/* In multi-tread, we need only one thread to process
 	 * events on the pipe with master