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.
This commit is contained in:
Christopher Faulet 2025-04-24 18:54:32 +02:00
parent 27b732a661
commit 101cc4f334

View File

@ -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