Patrick, Christian,

Could you try the attached patch? It should fix the issue.

Thanks


-- 
William Lallemand
>From 71dae971bf9b59ec8ef2f94cab2c0d762744c2a9 Mon Sep 17 00:00:00 2001
From: William Lallemand <[email protected]>
Date: Fri, 12 Apr 2019 14:40:36 +0200
Subject: [PATCH] BUG/MEDIUM: mworker/cli: don't override the stats_fe
 configuration

Patrick Hemmer reported that the stats bind-process directive does not
work anymore.

The worker's internal stats socket was using the global stats_fe
frontend, which is a problem since its configuration can be changed. The
bind-process configuration was overriden by the creation of the worker's
internal stats socket.

With this patch, the worker uses its own frontend which does not collide
anymore with the stats_fe.

This must be backported to 1.9
---
 src/cli.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/cli.c b/src/cli.c
index ef6280645..d3e4b6140 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -96,6 +96,7 @@ static struct cli_kw_list cli_keywords = {
 extern const char *stat_status_codes[];
 
 static struct proxy *mworker_proxy; /* CLI proxy of the master */
+static struct proxy *mworker_fe;    /* CLI frontend used in the workers */
 
 static char *cli_gen_usage_msg(struct appctx *appctx)
 {
@@ -2554,15 +2555,14 @@ int mworker_cli_sockpair_new(struct mworker_proc *mworker_proc, int proc)
 		return -1;
 	}
 
-	/* XXX: we might want to use a separate frontend at some point */
-	if (!global.stats_fe) {
-		if ((global.stats_fe = alloc_stats_fe("GLOBAL", "master-socket", 0)) == NULL) {
-			ha_alert("out of memory trying to allocate the stats frontend");
+	if (!mworker_fe) {
+		if ((mworker_fe = alloc_stats_fe("GLOBAL", "master-socket", 0)) == NULL) {
+			ha_alert("out of memory trying to allocate the mworker frontend");
 			goto error;
 		}
 	}
 
-	bind_conf = bind_conf_alloc(global.stats_fe, "master-socket", 0, "", xprt_get(XPRT_RAW));
+	bind_conf = bind_conf_alloc(mworker_fe, "master-socket", 0, "", xprt_get(XPRT_RAW));
 	if (!bind_conf)
 		goto error;
 
@@ -2570,14 +2570,14 @@ int mworker_cli_sockpair_new(struct mworker_proc *mworker_proc, int proc)
 	bind_conf->level |= ACCESS_LVL_ADMIN; /* TODO: need to lower the rights with a CLI keyword*/
 
 	bind_conf->bind_proc = 1UL << proc;
-	global.stats_fe->bind_proc = 0; /* XXX: we should be careful with that, it can be removed by configuration */
+	mworker_fe->bind_proc = 0;
 
 	if (!memprintf(&path, "sockpair@%d", mworker_proc->ipc_fd[1])) {
 		ha_alert("Cannot allocate listener.\n");
 		goto error;
 	}
 
-	if (!str2listener(path, global.stats_fe, bind_conf, "master-socket", 0, &err)) {
+	if (!str2listener(path, mworker_fe, bind_conf, "master-socket", 0, &err)) {
 		free(path);
 		ha_alert("Cannot create a CLI sockpair listener for process #%d\n", proc);
 		goto error;
@@ -2587,7 +2587,7 @@ int mworker_cli_sockpair_new(struct mworker_proc *mworker_proc, int proc)
 
 	list_for_each_entry(l, &bind_conf->listeners, by_bind) {
 		l->accept = session_accept_fd;
-		l->default_target = global.stats_fe->default_target;
+		l->default_target = mworker_fe->default_target;
 		l->options |= (LI_O_UNLIMITED | LI_O_NOSTOP);
 		/* it's a sockpair but we don't want to keep the fd in the master */
 		l->options &= ~LI_O_INHERITED;
-- 
2.21.0

Reply via email to