From: Willy Tarreau Date: Wed, 24 Apr 2024 16:44:03 +0000 (+0200) Subject: MEDIUM: dynbuf: generalize the use of b_dequeue() to detach buffer_wait X-Git-Tag: v3.0-dev11~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5566afec654acceb40f96b64bf46eee96f96c57;p=thirdparty%2Fhaproxy.git MEDIUM: dynbuf: generalize the use of b_dequeue() to detach buffer_wait Now thanks to this the bufq_map field is expected to remain accurate. --- diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h index 953e13cb70..663f890358 100644 --- a/include/haproxy/applet.h +++ b/include/haproxy/applet.h @@ -121,8 +121,7 @@ static inline void __appctx_free(struct appctx *appctx) appctx_release_buf(appctx, &appctx->outbuf); task_destroy(appctx->t); - if (LIST_INLIST(&appctx->buffer_wait.list)) - LIST_DEL_INIT(&appctx->buffer_wait.list); + b_dequeue(&appctx->buffer_wait); if (appctx->sess) session_free(appctx->sess); BUG_ON(appctx->sedesc && !se_fl_test(appctx->sedesc, SE_FL_ORPHAN)); diff --git a/src/applet.c b/src/applet.c index dca53e7888..0297829790 100644 --- a/src/applet.c +++ b/src/applet.c @@ -405,8 +405,7 @@ void appctx_shut(struct appctx *appctx) appctx->applet->release(appctx); applet_fl_set(appctx, APPCTX_FL_SHUTDOWN); - if (LIST_INLIST(&appctx->buffer_wait.list)) - LIST_DEL_INIT(&appctx->buffer_wait.list); + b_dequeue(&appctx->buffer_wait); TRACE_LEAVE(APPLET_EV_RELEASE, appctx); } diff --git a/src/check.c b/src/check.c index d00ea265a8..64464c4f4f 100644 --- a/src/check.c +++ b/src/check.c @@ -1415,8 +1415,7 @@ struct task *process_chk_conn(struct task *t, void *context, unsigned int state) } } - if (LIST_INLIST(&check->buf_wait.list)) - LIST_DEL_INIT(&check->buf_wait.list); + b_dequeue(&check->buf_wait); check_release_buf(check, &check->bi); check_release_buf(check, &check->bo); diff --git a/src/flt_spoe.c b/src/flt_spoe.c index f8718f01a5..2ac03d6d28 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -2852,8 +2852,7 @@ spoe_acquire_buffer(struct buffer *buf, struct buffer_wait *buffer_wait) if (buf->size) return 1; - if (LIST_INLIST(&buffer_wait->list)) - LIST_DEL_INIT(&buffer_wait->list); + b_dequeue(buffer_wait); if (b_alloc(buf, DB_CHANNEL)) return 1; @@ -2865,8 +2864,7 @@ spoe_acquire_buffer(struct buffer *buf, struct buffer_wait *buffer_wait) static void spoe_release_buffer(struct buffer *buf, struct buffer_wait *buffer_wait) { - if (LIST_INLIST(&buffer_wait->list)) - LIST_DEL_INIT(&buffer_wait->list); + b_dequeue(buffer_wait); /* Release the buffer if needed */ if (buf->size) { diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index e8a7190545..7008a72493 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -753,8 +753,7 @@ static void fcgi_release(struct fcgi_conn *fconn) TRACE_POINT(FCGI_EV_FCONN_END); - if (LIST_INLIST(&fconn->buf_wait.list)) - LIST_DEL_INIT(&fconn->buf_wait.list); + b_dequeue(&fconn->buf_wait); fcgi_release_buf(fconn, &fconn->dbuf); fcgi_release_mbuf(fconn); diff --git a/src/mux_h1.c b/src/mux_h1.c index 4839e432eb..dbd93a9b4f 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -1238,9 +1238,7 @@ static void h1_release(struct h1c *h1c) } - if (LIST_INLIST(&h1c->buf_wait.list)) - LIST_DEL_INIT(&h1c->buf_wait.list); - + b_dequeue(&h1c->buf_wait); h1_release_buf(h1c, &h1c->ibuf); h1_release_buf(h1c, &h1c->obuf); diff --git a/src/mux_h2.c b/src/mux_h2.c index 9f2bef246c..82ed4cb14b 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -1193,8 +1193,7 @@ static void h2_release(struct h2c *h2c) hpack_dht_free(h2c->ddht); - if (LIST_INLIST(&h2c->buf_wait.list)) - LIST_DEL_INIT(&h2c->buf_wait.list); + b_dequeue(&h2c->buf_wait); h2_release_buf(h2c, &h2c->dbuf); h2_release_mbuf(h2c); diff --git a/src/stream.c b/src/stream.c index 6699585303..a50294251f 100644 --- a/src/stream.c +++ b/src/stream.c @@ -632,8 +632,7 @@ void stream_free(struct stream *s) } /* We may still be present in the buffer wait queue */ - if (LIST_INLIST(&s->buffer_wait.list)) - LIST_DEL_INIT(&s->buffer_wait.list); + b_dequeue(&s->buffer_wait); if (s->req.buf.size || s->res.buf.size) { int count = !!s->req.buf.size + !!s->res.buf.size;