From: Willy Tarreau Date: Sun, 26 May 2019 07:45:23 +0000 (+0200) Subject: MINOR: mux-h2: introduce h2_release_mbuf() to release all buffers in the mbuf ring X-Git-Tag: v2.0-dev5~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e3c000c1c955559e99fcefe52270c9dd2097f80;p=thirdparty%2Fhaproxy.git MINOR: mux-h2: introduce h2_release_mbuf() to release all buffers in the mbuf ring This function iterates over all buffers in the mbuf ring to release all of them from the head to the tail. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index 392848425f..5f19ccfa3e 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -432,6 +432,19 @@ static inline void h2_release_buf(struct h2c *h2c, struct buffer *bptr) } } +static inline void h2_release_mbuf(struct h2c *h2c) +{ + struct buffer *buf; + unsigned int count = 0; + + while (b_size(buf = br_head_pick(h2c->mbuf))) { + b_free(buf); + count++; + } + if (count) + offer_buffers(h2c->buf_wait.target, tasks_run_queue); +} + /* returns the number of allocatable outgoing streams for the connection taking * the last_sid and the reserved ones into account. */ @@ -654,7 +667,7 @@ static void h2_release(struct h2c *h2c) HA_SPIN_UNLOCK(BUF_WQ_LOCK, &buffer_wq_lock); h2_release_buf(h2c, &h2c->dbuf); - h2_release_buf(h2c, br_tail(h2c->mbuf)); + h2_release_mbuf(h2c); if (h2c->task) { h2c->task->context = NULL; @@ -2915,7 +2928,7 @@ static int h2_process(struct h2c *h2c) !br_data(h2c->mbuf) && (h2c->mws <= 0 || LIST_ISEMPTY(&h2c->fctl_list)) && ((h2c->flags & H2_CF_MUX_BLOCK_ANY) || LIST_ISEMPTY(&h2c->send_list)))) - h2_release_buf(h2c, br_tail(h2c->mbuf)); + h2_release_mbuf(h2c); if (h2c->task) { if (eb_is_empty(&h2c->streams_by_id) || br_data(h2c->mbuf)) {