BUG/MEDIUM: mworker: don't lose the stats socket on failed reload

In master mode, when the master reexecs itself, it passes the stats socket
address via "-x" on the command line. However, the address is first
retrieved from the configuration, and only later in the boot sequence
the one passed on the command line is considered. As such, some early
errors on reload like a missing config file will cause the process to
rexec itself with no stats socket address on the command line, preventing
the new master from retrieving previous listeners.

The right thing to do is to preset the value to the one found on the
command line so that it can be preserved across failed reloads.

There is no mainline equivalent for this commit because this code was
removed from 2.6, which now only uses the socket pair. The patch must
be backported to older versions where it applies.

(cherry picked from commit b8df64a85120195f40e0f55b9db54c95b72bbdcc)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/src/haproxy.c b/src/haproxy.c
index f5d4579..a1f9796 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -657,6 +657,9 @@
 
 static void get_cur_unixsocket()
 {
+	/* get rid of the one found on the command line for now */
+	ha_free(&cur_unixsocket);
+
 	/* if -x was used, try to update the stat socket if not available anymore */
 	if (global.cli_fe) {
 		struct bind_conf *bind_conf;
@@ -1656,6 +1659,10 @@
 					ha_warning("-x option already set, overwriting the value\n");
 				old_unixsocket = argv[1];
 
+				/* preset it now for early aborts */
+				free(cur_unixsocket);
+				cur_unixsocket = strdup(old_unixsocket);
+
 				argv++;
 				argc--;
 			}