From b6563f4ac407a6096a2b2d5126729c2668dc0493 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sat, 15 Jun 2019 11:34:41 +0200 Subject: [PATCH] BUG/MEDIUM: mux-h2: properly account for the appended data in HTX When commit 0350b90e3 ("MEDIUM: htx: make htx_add_data() never defragment the buffer") was introduced, it made htx_add_data() actually be able to add less data than it was asked for, and the callers must use the returned value to know how much was added. The H2 code used to rely on the frame length instead of the return value. A version of the code doing this was written but is obviously not the one that got merged, resulting in breaking large uploads or downloads when HTX would have instead defragmented the buffer because the HTX side sees less contents than what the H2 side sees. This patch fixes this again. No backport is needed. --- src/mux_h2.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mux_h2.c b/src/mux_h2.c index 790d5bb95..d02168df5 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -3814,13 +3814,13 @@ try_again: sent = htx_add_data(htx, ist2(b_head(&h2c->dbuf), flen)); - b_del(&h2c->dbuf, flen); - h2c->dfl -= flen; - h2c->rcvd_c += flen; - h2c->rcvd_s += flen; // warning, this can also affect the closed streams! + b_del(&h2c->dbuf, sent); + h2c->dfl -= sent; + h2c->rcvd_c += sent; + h2c->rcvd_s += sent; // warning, this can also affect the closed streams! if (h2s->flags & H2_SF_DATA_CLEN) { - h2s->body_len -= flen; + h2s->body_len -= sent; htx->extra = h2s->body_len; }