From b74bedf1579be48ddec1ed5e28b22647e790d991 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 11 Oct 2024 14:49:45 +0200 Subject: [PATCH] MINOR: mux-h2: simplify the wake up code in h2_rcv_buf() The code used to decide when to restart reading is far from being trivial and will cause trouble after the forthcoming changes: it checks if the current stream is the same that is being demuxed, and only if so, wakes the demux to restart reading. Once streams will start to use multiple buffers, this condition will make no sense anymore. Actually the real reason is split into two steps: - detect if the demux is currently blocked on the current stream, and if so remove SFULL - detect if any demux blocking flags were removed during the operations, and if so, wake demuxing. For now this doesn't change anything. --- src/mux_h2.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mux_h2.c b/src/mux_h2.c index 2ee5e270d0..0167dd9e9b 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -7193,6 +7193,7 @@ static size_t h2_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, in struct htx *h2s_htx = NULL; struct htx *buf_htx = NULL; size_t ret = 0; + uint prev_h2c_flags = h2c->flags; TRACE_ENTER(H2_EV_STRM_RECV, h2c->conn, h2s); @@ -7255,11 +7256,13 @@ static size_t h2_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, in h2s_propagate_term_flags(h2c, h2s); } - if (ret && h2c->dsi == h2s->id) { - /* demux is blocking on this stream's buffer */ + /* the demux might have been blocking on this stream's buffer */ + if (ret && h2c->dsi == h2s->id) h2c->flags &= ~H2_CF_DEM_SFULL; + + /* wake up processing if we've unblocked something */ + if ((prev_h2c_flags & ~h2c->flags) & H2_CF_DEM_SFULL) h2c_restart_reading(h2c, 1); - } TRACE_LEAVE(H2_EV_STRM_RECV, h2c->conn, h2s); return ret; -- 2.47.2