]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-h2: simplify the exit code in h2_rcv_buf()
authorWilly Tarreau <w@1wt.eu>
Wed, 2 Oct 2024 15:13:28 +0000 (17:13 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 12 Oct 2024 14:29:16 +0000 (16:29 +0200)
The code used to decide what to tell to the upper layer and when to free
the rxbuf is a bit convoluted and difficult to adapt to dynamic rxbufs.
We first need to deal with memory management (b_free) and only then to
decide what to report upwards. Right now it does it the other way around.

This should not change anything.

src/mux_h2.c

index 34653a233d3d6656cb6add94a6d3f9a88d89845a..2ee5e270d0adb65bd65449cc9407ed547a1c5624 100644 (file)
@@ -7234,6 +7234,13 @@ static size_t h2_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, in
        ret -= h2s_htx->data;
 
   end:
+       /* release the rxbuf if it's not used anymore */
+       if (!b_data(&h2s->rxbuf) && b_size(&h2s->rxbuf)) {
+               b_free(&h2s->rxbuf);
+               offer_buffers(NULL, 1);
+       }
+
+       /* tell the stream layer whether there are data left or not */
        if (b_data(&h2s->rxbuf))
                se_fl_set(h2s->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM);
        else {
@@ -7246,10 +7253,6 @@ static size_t h2_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, in
 
                se_fl_clr(h2s->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM);
                h2s_propagate_term_flags(h2c, h2s);
-               if (b_size(&h2s->rxbuf)) {
-                       b_free(&h2s->rxbuf);
-                       offer_buffers(NULL, 1);
-               }
        }
 
        if (ret && h2c->dsi == h2s->id) {