]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: channel: allocate without queuing when retrying
authorWilly Tarreau <w@1wt.eu>
Tue, 7 May 2024 15:52:11 +0000 (17:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 May 2024 15:18:13 +0000 (17:18 +0200)
Now when trying to allocate a channel buffer, we can check if we've been
notified of availability via the producer stream connector callback, in
which case we should not consult the queue, or if we're doing a first
allocation and check the queue.

include/haproxy/channel.h

index 6e0c35bc75b908d6144145f7fa0be3f91e7bfe29..22949e14531ebd1797e5d0432e65d3a4229622c8 100644 (file)
@@ -915,7 +915,14 @@ static inline int ci_space_for_replace(const struct channel *chn)
  */
 static inline int channel_alloc_buffer(struct channel *chn, struct buffer_wait *wait)
 {
-       if (b_alloc(&chn->buf, DB_CHANNEL) != NULL)
+       int force_noqueue;
+
+       /* If the producer has been notified of recent availability, we must
+        * not check the queue again.
+        */
+       force_noqueue = !!(chn_prod(chn)->flags & SC_FL_HAVE_BUFF);
+
+       if (b_alloc(&chn->buf, DB_CHANNEL | (force_noqueue ? DB_F_NOQUEUE : 0)) != NULL)
                return 1;
 
        b_requeue(DB_CHANNEL, wait);