]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: mux-h1: allocate without queuing when retrying
authorWilly Tarreau <w@1wt.eu>
Tue, 7 May 2024 15:36:13 +0000 (17:36 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 May 2024 15:18:13 +0000 (17:18 +0200)
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

index 8515b36b9cc485022f056d56fb77fdbfe9ab523d..d532c170829447e7c6a9829665bdd88b3a72c87f 100644 (file)
@@ -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;
        }