mirror of
https://github.com/haproxy/haproxy.git
synced 2026-03-14 14:42:13 -04:00
MINOR: cli: implement execution context for manually registered keywords
Keywords registered out of an initcall will have a TH_EX_CTX_CLI_KWL
execution context pointing to the keyword list. The report will indicate
the 5 first words of the first command of the list, e.g.:
exec_ctx: cli kwl starting with 'debug counters '
This should also work for CLI keywords registered in Lua.
This commit is contained in:
parent
5cd71f69ba
commit
17cbec485a
3 changed files with 14 additions and 0 deletions
|
|
@ -89,6 +89,7 @@ enum thread_exec_ctx_type {
|
|||
TH_EX_CTX_MUX, /* mux whose mux_ops is in .mux_ops */
|
||||
TH_EX_CTX_TASK, /* task or tasklet whose function is in .task */
|
||||
TH_EX_CTX_APPLET, /* applet whose applet is in .applet */
|
||||
TH_EX_CTX_CLI_KWL, /* CLI keyword list, using .cli_kwl */
|
||||
};
|
||||
|
||||
struct thread_exec_ctx {
|
||||
|
|
@ -105,6 +106,7 @@ struct thread_exec_ctx {
|
|||
const struct mux_ops *mux_ops; /* used with TH_EX_CTX_MUX */
|
||||
const struct task *(*task)(struct task *, void *, unsigned int); /* used with TH_EX_CTX_TASK */
|
||||
const struct applet *applet; /* used with TH_EX_CTX_APPLET */
|
||||
const struct cli_kw_list *cli_kwl; /* used with TH_EX_CTX_CLI_KWL */
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -410,6 +410,9 @@ void cli_register_kw(struct cli_kw_list *kw_list)
|
|||
if (caller_initcall) {
|
||||
kw->exec_ctx.type = TH_EX_CTX_INITCALL;
|
||||
kw->exec_ctx.initcall = caller_initcall;
|
||||
} else {
|
||||
kw->exec_ctx.type = TH_EX_CTX_CLI_KWL;
|
||||
kw->exec_ctx.cli_kwl = kw_list;
|
||||
}
|
||||
}
|
||||
LIST_APPEND(&cli_keywords.list, &kw_list->list);
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ extern void *__elf_aux_vector;
|
|||
#include <haproxy/api.h>
|
||||
#include <haproxy/applet.h>
|
||||
#include <haproxy/chunk.h>
|
||||
#include <haproxy/cli-t.h>
|
||||
#include <haproxy/compiler.h>
|
||||
#include <haproxy/dgram.h>
|
||||
#include <haproxy/global.h>
|
||||
|
|
@ -7555,6 +7556,14 @@ void chunk_append_thread_ctx(struct buffer *output, const struct thread_exec_ctx
|
|||
case TH_EX_CTX_APPLET:
|
||||
chunk_appendf(output,"applet '%s'", ctx->applet->name);
|
||||
break;
|
||||
case TH_EX_CTX_CLI_KWL:
|
||||
chunk_appendf(output,"cli kwl starting with '%s %s %s %s %s'",
|
||||
ctx->cli_kwl->kw[0].str_kw[0],
|
||||
ctx->cli_kwl->kw[0].str_kw[1] ? ctx->cli_kwl->kw[0].str_kw[1] : "",
|
||||
ctx->cli_kwl->kw[0].str_kw[2] ? ctx->cli_kwl->kw[0].str_kw[2] : "",
|
||||
ctx->cli_kwl->kw[0].str_kw[3] ? ctx->cli_kwl->kw[0].str_kw[3] : "",
|
||||
ctx->cli_kwl->kw[0].str_kw[4] ? ctx->cli_kwl->kw[0].str_kw[4] : "");
|
||||
break;
|
||||
default:
|
||||
chunk_appendf(output,"other ctx %p", ctx->pointer);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in a new issue