]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: cli: Be sure to drop all input data in END state
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 17 Feb 2025 13:49:34 +0000 (14:49 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 17 Feb 2025 14:31:07 +0000 (15:31 +0100)
Commit 7214dcd ("BUG/MEDIUM: applet: Don't pretend to have more data to
handle EOI/EOS/ERROR") revealed a bug with the CLI applet. Pending input
data when the applet is in CLI_ST_END state were never consumed or dropped,
leading to a wakeup loop.

The CLI applet implements its own snd_buf callback function. It is important
it consumes all pending input data. Otherwise, the applet is woken up in
loop until it empties the request buffer. Another way to fix the issue would
be to report an error. But in that case, it seems reasonnable to drop these
data.

The issue can be observed on reload, in master/worker mode, because of issue
about the last ACK message which was never consummed by the _getsocks()
command.

This patch should fix the issue #2862. It must be backported to 3.1 with the
commit above.

src/cli.c

index d22a62ea5c64aeb14908923464bb1fafbcd55927..1b6c0cbc647dd2f5777e1da789d1221a459c6c9a 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -924,6 +924,12 @@ size_t cli_snd_buf(struct appctx *appctx, struct buffer *buf, size_t count, unsi
 
        if (appctx->st0 == CLI_ST_INIT)
                cli_init(appctx);
+       else if (appctx->st0 == CLI_ST_END) {
+               /* drop all data on END state */
+               ret = count;
+               b_del(buf, ret);
+               goto end;
+       }
        else if (appctx->st0 != CLI_ST_GETREQ)
                goto end;