From: Willy Tarreau Date: Wed, 2 Oct 2024 15:13:28 +0000 (+0200) Subject: MINOR: mux-h2: simplify the exit code in h2_rcv_buf() X-Git-Tag: v3.1-dev10~84 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a0ed92f3ddcbd69b5760ba4afc92d8f0bd86818a;p=thirdparty%2Fhaproxy.git MINOR: mux-h2: simplify the exit code in h2_rcv_buf() 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. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index 34653a233d..2ee5e270d0 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -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) {