From 396f0252bf3a400c9dbfdaf730e994bb44f198dd Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 16 Jun 2025 15:48:04 +0200 Subject: [PATCH] BUG/MEDIUM: cli: Don't consume data if outbuf is full or not available The output buffer must be available to process a command, at least to be able to emit error messages. When this buffer is full or cannot be allocated, we must wait. In that case, we must take care to notify the SE will not consume input data. It is important to avoid wakeup in loop, especially when the client aborts. When the output buffer is available again and no longer full, and the CLI applet is waiting for a command line, it must notify it will consume input data. This patch must be backported as far as 3.0. --- src/cli.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cli.c b/src/cli.c index 49e8e3502..f76a91dcf 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1086,10 +1086,9 @@ int cli_parse_cmdline(struct appctx *appctx) */ void cli_io_handler(struct appctx *appctx) { - if (applet_fl_test(appctx, APPCTX_FL_OUTBLK_ALLOC|APPCTX_FL_OUTBLK_FULL)) - goto out; - - if (!appctx_get_buf(appctx, &appctx->outbuf)) { + if (applet_fl_test(appctx, APPCTX_FL_OUTBLK_ALLOC|APPCTX_FL_OUTBLK_FULL) || + !appctx_get_buf(appctx, &appctx->outbuf)) { + applet_wont_consume(appctx); goto out; } @@ -1108,6 +1107,7 @@ void cli_io_handler(struct appctx *appctx) break; } else if (appctx->st0 == CLI_ST_PARSE_CMDLINE) { + applet_will_consume(appctx); if (cli_parse_cmdline(appctx) == 0) { /* Now we close the output if we're not in interactive * mode and the request buffer is empty. This still