]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: cli: Handle applet shutdown when waiting for a command line
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 24 Apr 2025 16:54:32 +0000 (18:54 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 25 Apr 2025 06:47:05 +0000 (08:47 +0200)
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.

src/cli.c

index 66908bd4a20b96d3f7171f5a97330a18e06c6014..f9b65d66f0e37e4635b72932d6b3d71e570ca8c7 100644 (file)
--- 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