BUG/MEDIUM: mux-h2: Truly drain outgoing HTX data when the stream is closed

It is the same bug than the previous one on the FCGI mux.

When we try to send data to the server and the stream is closed (in error,
in half-closed state or fully closed), remaining data must be drained. This
way the upper stream is able to properly handle the stream close.

However, there was a bug here. The mux claimed to have consumed these data
without draining them from the buffer. The issue was never reported on the
H2 multiplexer. But, in theory, the same than for the FCGI multiplexer is
possible.

Tihs patch must be backported to all supported versions.
This commit is contained in:
Christopher Faulet 2026-06-24 16:57:40 +02:00
parent 7668409cf2
commit f19e9c69f2

View file

@ -8186,11 +8186,14 @@ static size_t h2_snd_buf(struct stconn *sc, struct buffer *buf, size_t count, in
done:
if (h2s->st >= H2_SS_HLOC) {
struct htx_ret htxret;
/* trim any possibly pending data after we close (extra CR-LF,
* unprocessed trailers, abnormal extra data, ...)
*/
total += count;
count = 0;
htxret = htx_drain(htx, count);
total += htxret.ret;
count -= htxret.ret;
}
/* RST are sent similarly to frame acks */