]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mux-h2: unbreak receipt of large DATA frames
authorWilly Tarreau <w@1wt.eu>
Fri, 2 Aug 2019 05:48:47 +0000 (07:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 2 Aug 2019 11:37:55 +0000 (13:37 +0200)
Recent optimization in commit 4d7a88482 ("MEDIUM: mux-h2: don't try to
read more than needed") broke the receipt of large DATA frames because
it would unconditionally subscribe if there was some room left, thus
preventing any new rx from being done since subscription may only be
done once the end was reached, as indicated by ret == 0.

However, fixing this uncovered that in HTX mode previous versions might
occasionally be affected as well, when an available frame is the same
size as the maximum data that may fit into an HTX buffer, we may end
up reading that whole frame and still subscribe since it's still allowed
to receive, thus causing issues to read the next frame.

This patch will only work for 2.1-dev but a minor adaptation will be
needed for earlier versions (down to 1.9, where subscribe() was added).

src/mux_h2.c

index b58ba20bc0c025c1544c1046b724062a84820c80..a1da04191fb18b8563d53bc6927bbe5798b78275 100644 (file)
@@ -2753,7 +2753,7 @@ static int h2_recv(struct h2c *h2c)
 
        ret = max ? conn->xprt->rcv_buf(conn, conn->xprt_ctx, buf, max, 0) : 0;
 
-       if (h2_recv_allowed(h2c) && (b_data(buf) < buf->size))
+       if (max && !ret && h2_recv_allowed(h2c))
                conn->xprt->subscribe(conn, conn->xprt_ctx, SUB_RETRY_RECV, &h2c->wait_event);
 
        if (!b_data(buf)) {