CLEANUP: cli: rename the last few "stats_" to "cli_"
There were still a very small list of functions, variables and fields
called "stats_" while they were really purely CLI-centric. There's the
frontend called "stats_fe" in the global section, which instantiates a
"cli_applet" called "<CLI>" so it was renamed "cli_fe".
The "alloc_stats_fe" function cas renamed to "cli_alloc_fe" which also
better matches the naming convention of all cli-specific functions.
Finally the "stats_permission_denied_msg" used to return an error on
the CLI was renamed "cli_permission_denied_msg".
Now there's no more "stats_something" that designates the CLI.
diff --git a/include/haproxy/global-t.h b/include/haproxy/global-t.h
index 21de8c3..3bbdd72 100644
--- a/include/haproxy/global-t.h
+++ b/include/haproxy/global-t.h
@@ -156,7 +156,7 @@
mode_t mode; /* 0 to leave unchanged */
} ux;
} unix_bind;
- struct proxy *stats_fe; /* the frontend holding the stats settings */
+ struct proxy *cli_fe; /* the frontend holding the stats settings */
#ifdef USE_CPU_AFFINITY
struct {
unsigned long proc[MAX_PROCS]; /* list of CPU masks for the 32/64 first processes */
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 269b47d..8a0e9e7 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -145,7 +145,7 @@
}
ss2 = str2sa_range(str, NULL, &port, &end, &fd, &proto, err,
- curproxy == global.stats_fe ? NULL : global.unix_bind.prefix,
+ curproxy == global.cli_fe ? NULL : global.unix_bind.prefix,
NULL, PA_O_RESOLVE | PA_O_PORT_OK | PA_O_PORT_MAND | PA_O_PORT_RANGE |
PA_O_SOCKET_FD | PA_O_STREAM | PA_O_XPRT);
if (!ss2)
@@ -206,7 +206,7 @@
}
ss2 = str2sa_range(str, NULL, &port, &end, &fd, &proto, err,
- curproxy == global.stats_fe ? NULL : global.unix_bind.prefix,
+ curproxy == global.cli_fe ? NULL : global.unix_bind.prefix,
NULL, PA_O_RESOLVE | PA_O_PORT_OK | PA_O_PORT_MAND | PA_O_PORT_RANGE |
PA_O_SOCKET_FD | PA_O_DGRAM | PA_O_XPRT);
if (!ss2)
@@ -2132,7 +2132,7 @@
break;
}
- if (curproxy != global.stats_fe && (curproxy->cap & PR_CAP_FE) && LIST_ISEMPTY(&curproxy->conf.listeners)) {
+ if (curproxy != global.cli_fe && (curproxy->cap & PR_CAP_FE) && LIST_ISEMPTY(&curproxy->conf.listeners)) {
ha_warning("config : %s '%s' has no 'bind' directive. Please declare it as a backend if this was intended.\n",
proxy_type_str(curproxy), curproxy->id);
err_code |= ERR_WARN;
@@ -3338,18 +3338,18 @@
/* Check multi-process mode compatibility */
- if (global.nbproc > 1 && global.stats_fe) {
- list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
+ if (global.nbproc > 1 && global.cli_fe) {
+ list_for_each_entry(bind_conf, &global.cli_fe->conf.bind, by_fe) {
unsigned long mask;
- mask = proc_mask(global.stats_fe->bind_proc) && all_proc_mask;
+ mask = proc_mask(global.cli_fe->bind_proc) && all_proc_mask;
mask &= proc_mask(bind_conf->settings.bind_proc);
/* stop here if more than one process is used */
if (atleast2(mask))
break;
}
- if (&bind_conf->by_fe != &global.stats_fe->conf.bind) {
+ if (&bind_conf->by_fe != &global.cli_fe->conf.bind) {
ha_warning("stats socket will not work as expected in multi-process mode (nbproc > 1), you should force process binding globally using 'stats bind-process' or per socket using the 'process' attribute.\n");
}
}
@@ -3368,14 +3368,14 @@
curproxy->bind_proc = proc_mask(curproxy->bind_proc);
}
- if (global.stats_fe) {
- list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
+ if (global.cli_fe) {
+ list_for_each_entry(bind_conf, &global.cli_fe->conf.bind, by_fe) {
unsigned long mask;
mask = bind_conf->settings.bind_proc ? bind_conf->settings.bind_proc : 0;
- global.stats_fe->bind_proc |= mask;
+ global.cli_fe->bind_proc |= mask;
}
- global.stats_fe->bind_proc = proc_mask(global.stats_fe->bind_proc);
+ global.cli_fe->bind_proc = proc_mask(global.cli_fe->bind_proc);
}
/* propagate bindings from frontends to backends. Don't do it if there
diff --git a/src/cli.c b/src/cli.c
index 6859ad6..5ea040e 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -68,7 +68,7 @@
static struct applet cli_applet;
static struct applet mcli_applet;
-static const char stats_permission_denied_msg[] =
+static const char cli_permission_denied_msg[] =
"Permission denied\n"
"";
@@ -331,7 +331,7 @@
/* allocate a new stats frontend named <name>, and return it
* (or NULL in case of lack of memory).
*/
-static struct proxy *alloc_stats_fe(const char *name, const char *file, int line)
+static struct proxy *cli_alloc_fe(const char *name, const char *file, int line)
{
struct proxy *fe;
@@ -364,9 +364,9 @@
* '\n' must not be written. The function must be called with <args> pointing to
* the first word after "stats".
*/
-static int stats_parse_global(char **args, int section_type, struct proxy *curpx,
- const struct proxy *defpx, const char *file, int line,
- char **err)
+static int cli_parse_global(char **args, int section_type, struct proxy *curpx,
+ const struct proxy *defpx, const char *file, int line,
+ char **err)
{
struct bind_conf *bind_conf;
struct listener *l;
@@ -379,18 +379,18 @@
return -1;
}
- if (!global.stats_fe) {
- if ((global.stats_fe = alloc_stats_fe("GLOBAL", file, line)) == NULL) {
+ if (!global.cli_fe) {
+ if ((global.cli_fe = cli_alloc_fe("GLOBAL", file, line)) == NULL) {
memprintf(err, "'%s %s' : out of memory trying to allocate a frontend", args[0], args[1]);
return -1;
}
}
- bind_conf = bind_conf_alloc(global.stats_fe, file, line, args[2], xprt_get(XPRT_RAW));
+ bind_conf = bind_conf_alloc(global.cli_fe, file, line, args[2], xprt_get(XPRT_RAW));
bind_conf->level &= ~ACCESS_LVL_MASK;
bind_conf->level |= ACCESS_LVL_OPER; /* default access level */
- if (!str2listener(args[2], global.stats_fe, bind_conf, file, line, err)) {
+ if (!str2listener(args[2], global.cli_fe, bind_conf, file, line, err)) {
memprintf(err, "parsing [%s:%d] : '%s %s' : %s\n",
file, line, args[0], args[1], err && *err ? *err : "error");
return -1;
@@ -409,7 +409,7 @@
return -1;
}
- if (kw->parse(args, cur_arg, global.stats_fe, bind_conf, err) != 0) {
+ if (kw->parse(args, cur_arg, global.cli_fe, bind_conf, err) != 0) {
if (err && *err)
memprintf(err, "'%s %s' : '%s'", args[0], args[1], *err);
else
@@ -434,7 +434,7 @@
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 = global.cli_fe->default_target;
l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
l->nice = -64; /* we want to boost priority for local stats */
global.maxsock++; /* for the listening socket */
@@ -463,13 +463,13 @@
memprintf(err, "'%s %s' expects a positive value", args[0], args[1]);
return -1;
}
- if (!global.stats_fe) {
- if ((global.stats_fe = alloc_stats_fe("GLOBAL", file, line)) == NULL) {
+ if (!global.cli_fe) {
+ if ((global.cli_fe = cli_alloc_fe("GLOBAL", file, line)) == NULL) {
memprintf(err, "'%s %s' : out of memory trying to allocate a frontend", args[0], args[1]);
return -1;
}
}
- global.stats_fe->timeout.client = MS_TO_TICKS(timeout);
+ global.cli_fe->timeout.client = MS_TO_TICKS(timeout);
}
else if (strcmp(args[1], "maxconn") == 0) {
int maxconn = atol(args[2]);
@@ -479,20 +479,20 @@
return -1;
}
- if (!global.stats_fe) {
- if ((global.stats_fe = alloc_stats_fe("GLOBAL", file, line)) == NULL) {
+ if (!global.cli_fe) {
+ if ((global.cli_fe = cli_alloc_fe("GLOBAL", file, line)) == NULL) {
memprintf(err, "'%s %s' : out of memory trying to allocate a frontend", args[0], args[1]);
return -1;
}
}
- global.stats_fe->maxconn = maxconn;
+ global.cli_fe->maxconn = maxconn;
}
else if (strcmp(args[1], "bind-process") == 0) { /* enable the socket only on some processes */
int cur_arg = 2;
unsigned long set = 0;
- if (!global.stats_fe) {
- if ((global.stats_fe = alloc_stats_fe("GLOBAL", file, line)) == NULL) {
+ if (!global.cli_fe) {
+ if ((global.cli_fe = cli_alloc_fe("GLOBAL", file, line)) == NULL) {
memprintf(err, "'%s %s' : out of memory trying to allocate a frontend", args[0], args[1]);
return -1;
}
@@ -509,7 +509,7 @@
}
cur_arg++;
}
- global.stats_fe->bind_proc = set;
+ global.cli_fe->bind_proc = set;
}
else {
memprintf(err, "'%s' only supports 'socket', 'maxconn', 'bind-process' and 'timeout' (got '%s')", args[0], args[1]);
@@ -573,7 +573,7 @@
int cli_socket_setenv()
{
- if (listeners_setenv(global.stats_fe, "HAPROXY_CLI") < 0)
+ if (listeners_setenv(global.cli_fe, "HAPROXY_CLI") < 0)
return -1;
if (listeners_setenv(mworker_proxy, "HAPROXY_MASTER_CLI") < 0)
return -1;
@@ -592,7 +592,7 @@
{
if ((appctx->cli_level & ACCESS_LVL_MASK) < level) {
- cli_err(appctx, stats_permission_denied_msg);
+ cli_err(appctx, cli_permission_denied_msg);
return 0;
}
return 1;
@@ -1419,8 +1419,8 @@
/* fall through */
case STAT_ST_LIST:
- if (global.stats_fe) {
- list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
+ if (global.cli_fe) {
+ list_for_each_entry(bind_conf, &global.cli_fe->conf.bind, by_fe) {
struct listener *l;
/*
@@ -1429,7 +1429,7 @@
*/
if (appctx->ctx.cli.p0 &&
- &bind_conf->by_fe == (&global.stats_fe->conf.bind)->n) {
+ &bind_conf->by_fe == (&global.cli_fe->conf.bind)->n) {
/* change the current node to the latest dumped and continue the loop */
bind_conf = LIST_ELEM(appctx->ctx.cli.p0, typeof(bind_conf), by_fe);
continue;
@@ -2769,7 +2769,7 @@
goto err;
}
- if (kw->parse(args, cur_arg, global.stats_fe, bind_conf, &err) != 0) {
+ if (kw->parse(args, cur_arg, global.cli_fe, bind_conf, &err) != 0) {
if (err)
memprintf(&err, "'%s %s' : '%s'", args[0], args[1], err);
else
@@ -2832,14 +2832,14 @@
}
/* 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) {
+ if (!global.cli_fe) {
+ if ((global.cli_fe = cli_alloc_fe("GLOBAL", "master-socket", 0)) == NULL) {
ha_alert("out of memory trying to allocate the stats frontend");
goto error;
}
}
- bind_conf = bind_conf_alloc(global.stats_fe, "master-socket", 0, "", xprt_get(XPRT_RAW));
+ bind_conf = bind_conf_alloc(global.cli_fe, "master-socket", 0, "", xprt_get(XPRT_RAW));
if (!bind_conf)
goto error;
@@ -2847,14 +2847,14 @@
bind_conf->level |= ACCESS_LVL_ADMIN; /* TODO: need to lower the rights with a CLI keyword*/
bind_conf->settings.bind_proc = 1UL << proc;
- global.stats_fe->bind_proc = 0; /* XXX: we should be careful with that, it can be removed by configuration */
+ global.cli_fe->bind_proc = 0; /* XXX: we should be careful with that, it can be removed by configuration */
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, global.cli_fe, bind_conf, "master-socket", 0, &err)) {
free(path);
ha_alert("Cannot create a CLI sockpair listener for process #%d\n", proc);
goto error;
@@ -2863,7 +2863,7 @@
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 = global.cli_fe->default_target;
l->options |= (LI_O_UNLIMITED | LI_O_NOSTOP);
HA_ATOMIC_ADD(&unstoppable_jobs, 1);
/* it's a sockpair but we don't want to keep the fd in the master */
@@ -2921,7 +2921,7 @@
INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
static struct cfg_kw_list cfg_kws = {ILH, {
- { CFG_GLOBAL, "stats", stats_parse_global },
+ { CFG_GLOBAL, "stats", cli_parse_global },
{ 0, NULL, NULL },
}};
diff --git a/src/haproxy.c b/src/haproxy.c
index 7b30a78..89062b6 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -713,11 +713,11 @@
static void get_cur_unixsocket()
{
/* if -x was used, try to update the stat socket if not available anymore */
- if (global.stats_fe) {
+ if (global.cli_fe) {
struct bind_conf *bind_conf;
/* pass through all stats socket */
- list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
+ list_for_each_entry(bind_conf, &global.cli_fe->conf.bind, by_fe) {
struct listener *l;
list_for_each_entry(l, &bind_conf->listeners, by_bind) {
@@ -2069,8 +2069,8 @@
if (cfg_maxconn > 0)
global.maxconn = cfg_maxconn;
- if (global.stats_fe)
- global.maxsock += global.stats_fe->maxconn;
+ if (global.cli_fe)
+ global.maxsock += global.cli_fe->maxconn;
if (cfg_peers) {
/* peers also need to bypass global maxconn */
@@ -3537,10 +3537,10 @@
* Caution: the GTUNE_SOCKET_TRANSFER is now set after the fork.
* */
- if (global.stats_fe) {
+ if (global.cli_fe) {
struct bind_conf *bind_conf;
- list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
+ list_for_each_entry(bind_conf, &global.cli_fe->conf.bind, by_fe) {
if (bind_conf->level & ACCESS_FD_LISTENERS) {
if (!bind_conf->settings.bind_proc || bind_conf->settings.bind_proc & (1UL << proc)) {
global.tune.options |= GTUNE_SOCKET_TRANSFER;