From 47665be0835d0fd0cef37684da7ac0e547350701 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 7 May 2024 17:36:13 +0200 Subject: [PATCH] MEDIUM: mux-h1: allocate without queuing when retrying Now when trying to allocate a buffer, we can check if we've been notified of availability via the callback, in which case we should not consult the queue, or if we're doing a first allocation and check the queue. At this point it still doesn't change much since the stream still doesn't make use of it but some progress is expected. --- src/mux_h1.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mux_h1.c b/src/mux_h1.c index 8515b36b9..d532c1708 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -539,7 +539,8 @@ static inline struct buffer *h1_get_ibuf(struct h1c *h1c) { struct buffer *buf; - if (unlikely((buf = b_alloc(&h1c->ibuf, DB_MUX_RX)) == NULL)) { + if (unlikely((buf = b_alloc(&h1c->ibuf, DB_MUX_RX | + ((h1c->flags & H1C_F_IN_MAYALLOC) ? DB_F_NOQUEUE : 0))) == NULL)) { b_queue(DB_MUX_RX, &h1c->buf_wait, h1c, h1_buf_available); h1c->flags |= H1C_F_IN_ALLOC; } @@ -557,7 +558,8 @@ static inline struct buffer *h1_get_obuf(struct h1c *h1c) { struct buffer *buf; - if (unlikely((buf = b_alloc(&h1c->obuf, DB_MUX_TX)) == NULL)) { + if (unlikely((buf = b_alloc(&h1c->obuf, DB_MUX_TX | + ((h1c->flags & H1C_F_OUT_MAYALLOC) ? DB_F_NOQUEUE : 0))) == NULL)) { b_queue(DB_MUX_TX, &h1c->buf_wait, h1c, h1_buf_available); h1c->flags |= H1C_F_OUT_ALLOC; } @@ -576,7 +578,8 @@ static inline struct buffer *h1_get_rxbuf(struct h1s *h1s) struct h1c *h1c = h1s->h1c; struct buffer *buf; - if (unlikely((buf = b_alloc(&h1s->rxbuf, DB_SE_RX)) == NULL)) { + if (unlikely((buf = b_alloc(&h1s->rxbuf, DB_SE_RX | + ((h1c->flags & H1C_F_IN_SMAYALLOC) ? DB_F_NOQUEUE : 0))) == NULL)) { b_queue(DB_SE_RX, &h1c->buf_wait, h1c, h1_buf_available); h1c->flags |= H1C_F_IN_SALLOC; }