]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cli/wait: also pass up to 4 arguments to the external conditions
authorWilly Tarreau <w@1wt.eu>
Fri, 9 Feb 2024 19:09:59 +0000 (20:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 9 Feb 2024 19:38:08 +0000 (20:38 +0100)
Conditions will need to have context, arguments etc from the command line.
Since these will vary with time (otherwise we wouldn't wait), let's just
pass them as text (possibly pre-processed). We're starting with 4 strings
that are expected to be allocated by strdup() and are always sent to free()
upon release.

include/haproxy/cli-t.h
src/cli.c

index bc868683cf14366dbac6d0e85261ee7b65f58c45..4a11893ed6d487c879a43445f2d9459d6c2223ce 100644 (file)
@@ -101,6 +101,7 @@ struct cli_wait_ctx {
        uint start, deadline;    // both are in ticks.
        enum cli_wait_cond cond; // CLI_WAIT_COND_*
        enum cli_wait_err error; // CLI_WAIT_ERR_*
+       char *args[4];           // up to 4 args taken at parse time, all strduped
        const char *msg;         // static error message for failures if not NULL
 };
 
index 1cede7729ea2b4e985c191b5538c52392edc3969..786f2a24e60961abf201cc2b0b9649d120ab0db5 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -2116,6 +2116,7 @@ static void cli_release_wait(struct appctx *appctx)
 {
        struct cli_wait_ctx *ctx = appctx->svcctx;
        const char *msg;
+       int i;
 
        switch (ctx->error) {
        case CLI_WAIT_ERR_EXP:      msg = "Wait delay expired.\n"; break;
@@ -2124,6 +2125,9 @@ static void cli_release_wait(struct appctx *appctx)
        default:                    msg = "Done.\n"; break;
        }
 
+       for (i = 0; i < sizeof(ctx->args) / sizeof(ctx->args[0]); i++)
+               ha_free(&ctx->args[i]);
+
        if (ctx->error == CLI_WAIT_ERR_DONE)
                cli_msg(appctx, LOG_INFO, msg);
        else