From: Christopher Faulet Date: Thu, 24 Apr 2025 16:54:32 +0000 (+0200) Subject: BUG/MEDIUM: cli: Handle applet shutdown when waiting for a command line X-Git-Tag: v3.2-dev12~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=101cc4f3340a52abf6686460853c91ae4058116d;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: cli: Handle applet shutdown when waiting for a command line When the CLI applet was refactord in the commit 20ec1de21 ("MAJOR: cli: Refacor parsing and execution of pipelined commands"), a regression was introduced. The applet shutdown was not longer handled when the applet was waiting for the next command line. It is especially visible when a client timeout occurred because the client connexion is no longer closed. To fix the issue, the test on the SE_FL_SHW flag was reintroduced in CLI_ST_PARSE_CMDLINE state, but only is there is no pending input data. It is a 3.2-specific issue. No backport needed. --- diff --git a/src/cli.c b/src/cli.c index 66908bd4a..f9b65d66f 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1100,8 +1100,18 @@ void cli_io_handler(struct appctx *appctx) break; } else if (appctx->st0 == CLI_ST_PARSE_CMDLINE) { - if (cli_parse_cmdline(appctx) == 0) + 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 + * allows pipelined requests to be sent in + * non-interactive mode. + */ + if (se_fl_test(appctx->sedesc, SE_FL_SHW)) { + appctx->st0 = CLI_ST_END; + continue; + } break; + } } else if (appctx->st0 == CLI_ST_PROCESS_CMDLINE) { /* ensure we have some output room left in the event we