]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream: report that a buffer allocation succeeded
authorWilly Tarreau <w@1wt.eu>
Tue, 7 May 2024 15:45:31 +0000 (17:45 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 May 2024 15:18:13 +0000 (17:18 +0200)
When the buffer allocation callback is notified of a buffer availability,
it will now set a MAYALLOC flag on the stream so that the stream knows it
is allowed to bypass the queue checks. For now this is not used.

include/haproxy/stream-t.h
src/stream.c

index a5b719016d46b8b41b5b30279b8dfae96b6c8cdb..b96512e0c9a818272e634c4bc1db9900bb512212 100644 (file)
@@ -40,7 +40,7 @@
  */
 #define SF_DIRECT      0x00000001      /* connection made on the server matching the client cookie */
 #define SF_ASSIGNED    0x00000002      /* no need to assign a server to this stream */
-/* unused: 0x00000004 */
+#define SF_MAYALLOC     0x00000004      /* we were notified that a work buffer might be available now */
 #define SF_BE_ASSIGNED 0x00000008      /* a backend was assigned. Conns are accounted. */
 
 #define SF_FORCE_PRST  0x00000010      /* force persistence here, even if server is down */
@@ -116,9 +116,9 @@ static forceinline char *strm_show_flags(char *buf, size_t len, const char *deli
        _e(SF_ERR_MASK, SF_ERR_DOWN,     _e(SF_ERR_MASK, SF_ERR_KILLED,
        _e(SF_ERR_MASK, SF_ERR_UP,       _e(SF_ERR_MASK, SF_ERR_CHK_PORT))))))))))));
 
-       _(SF_DIRECT, _(SF_ASSIGNED, _(SF_BE_ASSIGNED, _(SF_FORCE_PRST,
+       _(SF_DIRECT, _(SF_ASSIGNED, _(SF_MAYALLOC, _(SF_BE_ASSIGNED, _(SF_FORCE_PRST,
        _(SF_MONITOR, _(SF_CURR_SESS, _(SF_CONN_EXP, _(SF_REDISP,
-       _(SF_IGNORE, _(SF_REDIRECTABLE, _(SF_HTX)))))))))));
+       _(SF_IGNORE, _(SF_REDIRECTABLE, _(SF_HTX))))))))))));
 
        /* epilogue */
        _(~0U);
index 693f7942afff03255c7ebb64acda5df86e2f7d93..234cc9c3ec105bbda2420490dd778927f82f6335 100644 (file)
@@ -326,6 +326,7 @@ int stream_buf_available(void *arg)
        if (!s->res.buf.size && !sc_ep_have_ff_data(s->scf) && s->scb->flags & SC_FL_NEED_BUFF)
                sc_have_buff(s->scb);
 
+       s->flags |= SF_MAYALLOC;
        task_wakeup(s->task, TASK_WOKEN_RES);
        return 1;
 
@@ -748,8 +749,10 @@ void stream_free(struct stream *s)
  */
 static int stream_alloc_work_buffer(struct stream *s)
 {
-       if (b_alloc(&s->res.buf, DB_CHANNEL))
+       if (b_alloc(&s->res.buf, DB_CHANNEL)) {
+               s->flags &= ~SF_MAYALLOC;
                return 1;
+       }
 
        b_requeue(DB_CHANNEL, &s->buffer_wait);
        return 0;