mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-16 18:46:54 +00:00
CLEANUP: cli: rename dynamic error printing state
Rename CLI_ST_PRINT_FREE to CLI_ST_PRINT_DYNERR. Most notably, this highlights that this is reserved to error printing. This is done to ensure consistency between CLI_ST_PRINT/CLI_ST_PRINT_DYN and CLI_ST_PRINT_ERR/CLI_ST_PRINT_DYNERR. The name is also consistent with the function cli_dynerr() which activates it.
This commit is contained in:
parent
9fbc84e571
commit
56f50a03b7
@ -97,7 +97,7 @@ static int flt_ot_cli_parse_debug(char **args, char *payload, struct appctx *app
|
||||
(void)memprintf(&msg, FLT_OT_CLI_CMD " : current debug level is %hhu", value);
|
||||
}
|
||||
|
||||
cmn_cli_set_msg(appctx, err, msg, CLI_ST_PRINT_FREE);
|
||||
cmn_cli_set_msg(appctx, err, msg, CLI_ST_PRINT_DYNERR);
|
||||
|
||||
FLT_OT_RETURN_INT(retval);
|
||||
}
|
||||
@ -137,7 +137,7 @@ static int flt_ot_cli_parse_disabled(char **args, char *payload, struct appctx *
|
||||
(void)memprintf(&msg, "%s%s" FLT_OT_CLI_CMD " : filter %sabled", FLT_OT_CLI_MSG_CAT(msg), value ? "dis" : "en");
|
||||
} FLT_OT_PROXIES_LIST_END();
|
||||
|
||||
cmn_cli_set_msg(appctx, NULL, msg, CLI_ST_PRINT_FREE);
|
||||
cmn_cli_set_msg(appctx, NULL, msg, CLI_ST_PRINT_DYNERR);
|
||||
|
||||
FLT_OT_RETURN_INT(retval);
|
||||
}
|
||||
@ -175,7 +175,7 @@ static int flt_ot_cli_parse_option(char **args, char *payload, struct appctx *ap
|
||||
(void)memprintf(&msg, "%s%s" FLT_OT_CLI_CMD " : filter set %s-errors", FLT_OT_CLI_MSG_CAT(msg), value ? "hard" : "soft");
|
||||
} FLT_OT_PROXIES_LIST_END();
|
||||
|
||||
cmn_cli_set_msg(appctx, NULL, msg, CLI_ST_PRINT_FREE);
|
||||
cmn_cli_set_msg(appctx, NULL, msg, CLI_ST_PRINT_DYNERR);
|
||||
|
||||
FLT_OT_RETURN_INT(retval);
|
||||
}
|
||||
@ -238,7 +238,7 @@ static int flt_ot_cli_parse_logging(char **args, char *payload, struct appctx *a
|
||||
} FLT_OT_PROXIES_LIST_END();
|
||||
}
|
||||
|
||||
cmn_cli_set_msg(appctx, err, msg, CLI_ST_PRINT_FREE);
|
||||
cmn_cli_set_msg(appctx, err, msg, CLI_ST_PRINT_DYNERR);
|
||||
|
||||
FLT_OT_RETURN_INT(retval);
|
||||
}
|
||||
@ -289,7 +289,7 @@ static int flt_ot_cli_parse_rate(char **args, char *payload, struct appctx *appc
|
||||
} FLT_OT_PROXIES_LIST_END();
|
||||
}
|
||||
|
||||
cmn_cli_set_msg(appctx, err, msg, CLI_ST_PRINT_FREE);
|
||||
cmn_cli_set_msg(appctx, err, msg, CLI_ST_PRINT_DYNERR);
|
||||
|
||||
FLT_OT_RETURN_INT(retval);
|
||||
}
|
||||
@ -343,7 +343,7 @@ static int flt_ot_cli_parse_status(char **args, char *payload, struct appctx *ap
|
||||
nl = "\n";
|
||||
} FLT_OT_PROXIES_LIST_END();
|
||||
|
||||
cmn_cli_set_msg(appctx, NULL, msg, CLI_ST_PRINT_FREE);
|
||||
cmn_cli_set_msg(appctx, NULL, msg, CLI_ST_PRINT_DYNERR);
|
||||
|
||||
FLT_OT_RETURN_INT(retval);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ enum {
|
||||
CLI_ST_PRINT, /* display const message in cli->msg */
|
||||
CLI_ST_PRINT_ERR, /* display const error in cli->msg */
|
||||
CLI_ST_PRINT_DYN, /* display dynamic message in cli->err. After the display, free the pointer */
|
||||
CLI_ST_PRINT_FREE, /* display dynamic error in cli->err. After the display, free the pointer */
|
||||
CLI_ST_PRINT_DYNERR, /* display dynamic error in cli->err. After the display, free the pointer */
|
||||
CLI_ST_CALLBACK, /* custom callback pointer */
|
||||
};
|
||||
|
||||
@ -72,7 +72,7 @@ enum {
|
||||
/* CLI context for printing command responses. */
|
||||
struct cli_print_ctx {
|
||||
const char *msg; /* pointer to a persistent message to be returned in CLI_ST_PRINT state */
|
||||
char *err; /* pointer to a 'must free' message to be returned in CLI_ST_PRINT_FREE state */
|
||||
char *err; /* pointer to a 'must free' message to be returned in CLI_ST_PRINT_DYN state */
|
||||
int severity; /* severity of the message to be returned according to (syslog) rfc5424 */
|
||||
};
|
||||
|
||||
|
@ -104,7 +104,7 @@ static inline int cli_dynerr(struct appctx *appctx, char *err)
|
||||
struct cli_print_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
|
||||
|
||||
ctx->err = err;
|
||||
appctx->st0 = CLI_ST_PRINT_FREE;
|
||||
appctx->st0 = CLI_ST_PRINT_DYNERR;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
12
src/cli.c
12
src/cli.c
@ -1041,7 +1041,7 @@ static void cli_io_handler(struct appctx *appctx)
|
||||
case CLI_ST_PRINT: /* print const message in msg */
|
||||
case CLI_ST_PRINT_ERR: /* print const error in msg */
|
||||
case CLI_ST_PRINT_DYN: /* print dyn message in msg, free */
|
||||
case CLI_ST_PRINT_FREE: /* print dyn error in err, free */
|
||||
case CLI_ST_PRINT_DYNERR: /* print dyn error in err, free */
|
||||
/* the message is in the svcctx */
|
||||
ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
|
||||
if (appctx->st0 == CLI_ST_PRINT || appctx->st0 == CLI_ST_PRINT_ERR) {
|
||||
@ -1049,8 +1049,8 @@ static void cli_io_handler(struct appctx *appctx)
|
||||
LOG_ERR : ctx->severity;
|
||||
msg = ctx->msg;
|
||||
}
|
||||
else if (appctx->st0 == CLI_ST_PRINT_DYN || appctx->st0 == CLI_ST_PRINT_FREE) {
|
||||
sev = appctx->st0 == CLI_ST_PRINT_FREE ?
|
||||
else if (appctx->st0 == CLI_ST_PRINT_DYN || appctx->st0 == CLI_ST_PRINT_DYNERR) {
|
||||
sev = appctx->st0 == CLI_ST_PRINT_DYNERR ?
|
||||
LOG_ERR : ctx->severity;
|
||||
msg = ctx->err;
|
||||
if (!msg) {
|
||||
@ -1064,8 +1064,8 @@ static void cli_io_handler(struct appctx *appctx)
|
||||
}
|
||||
|
||||
if (cli_output_msg(res, msg, sev, cli_get_severity_output(appctx)) != -1) {
|
||||
if (appctx->st0 == CLI_ST_PRINT_FREE ||
|
||||
appctx->st0 == CLI_ST_PRINT_DYN) {
|
||||
if (appctx->st0 == CLI_ST_PRINT_DYN ||
|
||||
appctx->st0 == CLI_ST_PRINT_DYNERR) {
|
||||
ha_free(&ctx->err);
|
||||
}
|
||||
appctx->st0 = CLI_ST_PROMPT;
|
||||
@ -1193,7 +1193,7 @@ static void cli_release_handler(struct appctx *appctx)
|
||||
appctx->io_release(appctx);
|
||||
appctx->io_release = NULL;
|
||||
}
|
||||
else if (appctx->st0 == CLI_ST_PRINT_FREE || appctx->st0 == CLI_ST_PRINT_DYN) {
|
||||
else if (appctx->st0 == CLI_ST_PRINT_DYN || appctx->st0 == CLI_ST_PRINT_DYNERR) {
|
||||
struct cli_print_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
|
||||
|
||||
ha_free(&ctx->err);
|
||||
|
Loading…
Reference in New Issue
Block a user