From 24953fff90f9d04b684859e8134cba3c43653ea1 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. (cherry picked from commit 396f0252bf3a400c9dbfdaf730e994bb44f198dd) Signed-off-by: Christopher Faulet (cherry picked from commit de668f5eb86f0370357042badc07a90e5d565576) Signed-off-by: Christopher Faulet (cherry picked from commit 6072496521b2feb0ffcae5b72b95adff10291b7b) Signed-off-by: Christopher Faulet --- src/cli.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cli.c b/src/cli.c index 43e165b..7a3c1d2 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1062,10 +1062,9 @@ size_t cli_snd_buf(struct appctx *appctx, struct buffer *buf, size_t count, unsi */ 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; } @@ -1084,6 +1083,8 @@ void cli_io_handler(struct appctx *appctx) break; } else if (appctx->st0 == CLI_ST_GETREQ) { + applet_will_consume(appctx); + /* Now we close the output if we're not in interactive * mode and the request buffer is empty. This still * allows pipelined requests to be sent in -- 1.7.10.4