BUG/MEDIUM: cli: Be sure to drop all input data in END state

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.
This commit is contained in:
Christopher Faulet 2025-02-17 14:49:34 +01:00
parent ab2fa95bdd
commit 972ce87676

View File

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