From: Willy Tarreau Date: Tue, 7 May 2024 15:45:31 +0000 (+0200) Subject: MINOR: stream: report that a buffer allocation succeeded X-Git-Tag: v3.0-dev11~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=17d8916bb1c74cb20341c8565f34cbb0224f0a5b;p=thirdparty%2Fhaproxy.git MINOR: stream: report that a buffer allocation succeeded 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. --- diff --git a/include/haproxy/stream-t.h b/include/haproxy/stream-t.h index a5b719016d..b96512e0c9 100644 --- a/include/haproxy/stream-t.h +++ b/include/haproxy/stream-t.h @@ -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); diff --git a/src/stream.c b/src/stream.c index 693f7942af..234cc9c3ec 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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;