BUG/MEDIUM: mworker: proc_self incorrectly set crashes upon reload

When updating from 2.4 to 2.6, the child->reloads++ instruction changed
place, resulting in a former worker from the 2.4 process, still
identified as a current worker once in 2.6, because its reload counter
is still 0.

Unfortunately this counter is used to chose the mworker_proc structure
that will be used for the new worker.

What happens next, is that the mworker_proc structure of the previous
process is selected, and this one has ipc_fd[1] set to -1, because this
structure was supposed to be in the master.

The process then forks, and mworker_sockpair_register_per_thread() tries
to register ipc_fd[1] which is set to -1, instead of the fd of the new
socketpair.

This patch fixes the issue by checking if child->pid is equal to -1 when
selecting proc_self. This way we could be sure it wasn't a previous
process.

Should fix issue #1785.

This must be backported as far as 2.4 to fix the issue related to the
reload computation difference. However backporting it in every stable
branch will enforce the reload process.

(cherry picked from commit d4835a9680126f0059349fc7d81b741dc29a7428)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 80419fcff82b40669f901c79141cbfbb45e9fdb3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 736f266eb7fbf09be7b9a1b82536525e0df074ac)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
1 file changed