]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: cli: Notify cli applet won't consume data during request processing
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 1 Jun 2022 15:25:42 +0000 (17:25 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 13 Jun 2022 12:33:30 +0000 (14:33 +0200)
The CLI applet process one request after another. Thus, when several
requests are pipelined, it is important to notify it won't consume remaining
outgoing data while it is processing a request. Otherwise, the applet may be
woken up in loop. For instance, it may happen with the HTTP client while we
are waiting for the server response if a shutr is received.

This patch must be backported in all supported versions after an observation
period. But a massive refactoring was performed in 2.6. So, for the 2.5 and
below, the patch will have to be adapted. Note also that, AFAIK, the bug can
only be triggered by the HTTP client for now.

src/cli.c

index 5cb34cbf43687c8512fb264d3131059482534b7c..bd77418fe596e9493cf0075b29e403302dde15fc 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1136,8 +1136,10 @@ static void cli_io_handler(struct appctx *appctx)
                        }
 
                        /* If the output functions are still there, it means they require more room. */
-                       if (appctx->st0 >= CLI_ST_OUTPUT)
+                       if (appctx->st0 >= CLI_ST_OUTPUT) {
+                               applet_wont_consume(appctx);
                                break;
+                       }
 
                        /* Now we close the output if one of the writers did so,
                         * or if we're not in interactive mode and the request
@@ -1152,6 +1154,8 @@ static void cli_io_handler(struct appctx *appctx)
 
                        /* switch state back to GETREQ to read next requests */
                        appctx->st0 = CLI_ST_GETREQ;
+                       applet_will_consume(appctx);
+
                        /* reactivate the \n at the end of the response for the next command */
                        appctx->st1 &= ~APPCTX_CLI_ST1_NOLF;