]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cli: handle EOS/ERROR first
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 16 Jun 2025 14:29:07 +0000 (16:29 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 16 Jun 2025 14:47:59 +0000 (16:47 +0200)
It is not especially a bug fixed. But APPCTX_FL_EOS and APPCTX_FL_ERROR
flags must be handled first. These flags are set by the applet itself and
should mark the end of all processing. So there is not reason to get the
output buffer in first place.

This patch could be backported as far as 3.0.

src/cli.c

index f76a91dcfef5a777f843f862a589fec2f30c397c..875b68c10c6a47114d4e11fcaf5cb6148deaee30 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1086,17 +1086,18 @@ 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) ||
-           !appctx_get_buf(appctx, &appctx->outbuf)) {
-                applet_wont_consume(appctx);
-               goto out;
-       }
 
        if (unlikely(applet_fl_test(appctx, APPCTX_FL_EOS|APPCTX_FL_ERROR))) {
                appctx->st0 = CLI_ST_END;
                goto out;
        }
 
+       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;
+       }
+
        while (1) {
                if (appctx->st0 == CLI_ST_INIT) {
                        /* reset severity to default at init */