]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mux-h2: properly account for the appended data in HTX
authorWilly Tarreau <w@1wt.eu>
Sat, 15 Jun 2019 09:34:41 +0000 (11:34 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 15 Jun 2019 09:42:01 +0000 (11:42 +0200)
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

index 790d5bb95dba957c2742f18af94cb2e79c6c29de..d02168df5ae3ee9cf8e3223f03455da6873ac7a6 100644 (file)
@@ -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;
                }