From: Willy Tarreau Date: Wed, 24 Apr 2024 15:02:23 +0000 (+0200) Subject: MINOR: dynbuf: use the b_queue()/b_requeue() functions everywhere X-Git-Tag: v3.0-dev11~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a214197ce73929be0900e42385dd010e1905b0b0;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h index baa6402848..953e13cb70 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 54f1e297ce..6e0c35bc75 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 3a72b0c3dc..d00ea265a8 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 562e7c36fd..f8718f01a5 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 71609532f7..e8a7190545 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 a886c00c3c..4839e432eb 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 28dd457df6..9f2bef246c 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; }