From a214197ce73929be0900e42385dd010e1905b0b0 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 24 Apr 2024 17:02:23 +0200 Subject: [PATCH] MINOR: dynbuf: use the b_queue()/b_requeue() functions everywhere The code places that were used to manipulate the buffer_wq manually now just call b_queue() or b_requeue(). This will simplify the multiple list management later. --- include/haproxy/applet.h | 6 ++---- include/haproxy/channel.h | 4 +--- src/check.c | 4 +--- src/flt_spoe.c | 2 +- src/mux_fcgi.c | 4 +--- src/mux_h1.c | 4 +--- src/mux_h2.c | 4 +--- 7 files changed, 8 insertions(+), 20 deletions(-) diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h index baa640284..953e13cb7 100644 --- a/include/haproxy/applet.h +++ b/include/haproxy/applet.h @@ -91,10 +91,8 @@ static inline struct buffer *appctx_get_buf(struct appctx *appctx, struct buffer struct buffer *buf = NULL; if (likely(!LIST_INLIST(&appctx->buffer_wait.list)) && - unlikely((buf = b_alloc(bptr, DB_CHANNEL)) == NULL)) { - appctx->buffer_wait.target = appctx; - appctx->buffer_wait.wakeup_cb = appctx_buf_available; - LIST_APPEND(&th_ctx->buffer_wq, &appctx->buffer_wait.list); + unlikely((buf = b_alloc(bptr, DB_SE_RX)) == NULL)) { + b_queue(DB_SE_RX, &appctx->buffer_wait, appctx, appctx_buf_available); } return buf; } diff --git a/include/haproxy/channel.h b/include/haproxy/channel.h index 54f1e297c..6e0c35bc7 100644 --- a/include/haproxy/channel.h +++ b/include/haproxy/channel.h @@ -918,9 +918,7 @@ static inline int channel_alloc_buffer(struct channel *chn, struct buffer_wait * if (b_alloc(&chn->buf, DB_CHANNEL) != NULL) return 1; - if (!LIST_INLIST(&wait->list)) - LIST_APPEND(&th_ctx->buffer_wq, &wait->list); - + b_requeue(DB_CHANNEL, wait); return 0; } diff --git a/src/check.c b/src/check.c index 3a72b0c3d..d00ea265a 100644 --- a/src/check.c +++ b/src/check.c @@ -1530,9 +1530,7 @@ struct buffer *check_get_buf(struct check *check, struct buffer *bptr) if (likely(!LIST_INLIST(&check->buf_wait.list)) && unlikely((buf = b_alloc(bptr, DB_CHANNEL)) == NULL)) { - check->buf_wait.target = check; - check->buf_wait.wakeup_cb = check_buf_available; - LIST_APPEND(&th_ctx->buffer_wq, &check->buf_wait.list); + b_queue(DB_CHANNEL, &check->buf_wait, check, check_buf_available); } return buf; } diff --git a/src/flt_spoe.c b/src/flt_spoe.c index 562e7c36f..f8718f01a 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -2858,7 +2858,7 @@ spoe_acquire_buffer(struct buffer *buf, struct buffer_wait *buffer_wait) if (b_alloc(buf, DB_CHANNEL)) return 1; - LIST_APPEND(&th_ctx->buffer_wq, &buffer_wait->list); + b_requeue(DB_CHANNEL, buffer_wait); return 0; } diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index 71609532f..e8a719054 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -524,9 +524,7 @@ static inline struct buffer *fcgi_get_buf(struct fcgi_conn *fconn, struct buffer if (likely(!LIST_INLIST(&fconn->buf_wait.list)) && unlikely((buf = b_alloc(bptr, DB_MUX_RX)) == NULL)) { - fconn->buf_wait.target = fconn; - fconn->buf_wait.wakeup_cb = fcgi_buf_available; - LIST_APPEND(&th_ctx->buffer_wq, &fconn->buf_wait.list); + b_queue(DB_MUX_RX, &fconn->buf_wait, fconn, fcgi_buf_available); } return buf; } diff --git a/src/mux_h1.c b/src/mux_h1.c index a886c00c3..4839e432e 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -536,9 +536,7 @@ static inline struct buffer *h1_get_buf(struct h1c *h1c, struct buffer *bptr) if (likely(!LIST_INLIST(&h1c->buf_wait.list)) && unlikely((buf = b_alloc(bptr, DB_MUX_RX)) == NULL)) { - h1c->buf_wait.target = h1c; - h1c->buf_wait.wakeup_cb = h1_buf_available; - LIST_APPEND(&th_ctx->buffer_wq, &h1c->buf_wait.list); + b_queue(DB_MUX_RX, &h1c->buf_wait, h1c, h1_buf_available); } return buf; } diff --git a/src/mux_h2.c b/src/mux_h2.c index 28dd457df..9f2bef246 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -845,9 +845,7 @@ static inline struct buffer *h2_get_buf(struct h2c *h2c, struct buffer *bptr) if (likely(!LIST_INLIST(&h2c->buf_wait.list)) && unlikely((buf = b_alloc(bptr, DB_MUX_RX)) == NULL)) { - h2c->buf_wait.target = h2c; - h2c->buf_wait.wakeup_cb = h2_buf_available; - LIST_APPEND(&th_ctx->buffer_wq, &h2c->buf_wait.list); + b_queue(DB_MUX_RX, &h2c->buf_wait, h2c, h2_buf_available); } return buf; }