]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-h2: Set HTX extra value when possible
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 18 Feb 2019 15:04:35 +0000 (16:04 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 19 Feb 2019 15:26:14 +0000 (16:26 +0100)
For now, this can be only done when a content-length is specified. In fact, it
is the same value than h2s->body_len, the remaining body length according to
content-length. Setting this field allows the fast forwarding at the channel
layer, improving significantly data transfer for big objects.

This patch may be backported to 1.9.

src/mux_h2.c

index 17b8afaefb0a32b275b5b1771ce27914acb03b83..725074ea126f8ef5594db2bef781eb141ed50b42 100644 (file)
@@ -3404,8 +3404,11 @@ next_frame:
 
        if (msgf & H2_MSGF_BODY) {
                /* a payload is present */
-               if (msgf & H2_MSGF_BODY_CL)
+               if (msgf & H2_MSGF_BODY_CL) {
                        *flags |= H2_SF_DATA_CLEN;
+                       if (htx)
+                               htx->extra = *body_len;
+               }
                else if (!(msgf & H2_MSGF_BODY_TUNNEL) && !htx)
                        *flags |= H2_SF_DATA_CHNK;
        }
@@ -3565,8 +3568,10 @@ try_again:
                h2c->rcvd_c += flen;
                h2c->rcvd_s += flen;  // warning, this can also affect the closed streams!
 
-               if (h2s->flags & H2_SF_DATA_CLEN)
+               if (h2s->flags & H2_SF_DATA_CLEN) {
                        h2s->body_len -= flen;
+                       htx->extra = h2s->body_len;
+               }
                goto try_again;
        }
        else if (unlikely(b_space_wraps(csbuf))) {
@@ -5108,8 +5113,7 @@ static size_t h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t coun
                }
 
                htx_ret = htx_xfer_blks(buf_htx, h2s_htx, count, HTX_BLK_EOM);
-
-               buf_htx->extra = h2s_htx->extra;
+               buf_htx->extra = (h2s_htx->extra ? (h2s_htx->data + h2s_htx->extra) : 0);
                htx_to_buf(buf_htx, buf);
                htx_to_buf(h2s_htx, &h2s->rxbuf);
                ret = htx_ret.ret;