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.
This commit is contained in:
Willy Tarreau 2024-05-07 17:45:31 +02:00
parent 7aff64518c
commit 17d8916bb1
2 changed files with 7 additions and 4 deletions

View File

@ -40,7 +40,7 @@
*/ */
#define SF_DIRECT 0x00000001 /* connection made on the server matching the client cookie */ #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 */ #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_BE_ASSIGNED 0x00000008 /* a backend was assigned. Conns are accounted. */
#define SF_FORCE_PRST 0x00000010 /* force persistence here, even if server is down */ #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_DOWN, _e(SF_ERR_MASK, SF_ERR_KILLED,
_e(SF_ERR_MASK, SF_ERR_UP, _e(SF_ERR_MASK, SF_ERR_CHK_PORT)))))))))))); _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_MONITOR, _(SF_CURR_SESS, _(SF_CONN_EXP, _(SF_REDISP,
_(SF_IGNORE, _(SF_REDIRECTABLE, _(SF_HTX))))))))))); _(SF_IGNORE, _(SF_REDIRECTABLE, _(SF_HTX))))))))))));
/* epilogue */ /* epilogue */
_(~0U); _(~0U);

View 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) if (!s->res.buf.size && !sc_ep_have_ff_data(s->scf) && s->scb->flags & SC_FL_NEED_BUFF)
sc_have_buff(s->scb); sc_have_buff(s->scb);
s->flags |= SF_MAYALLOC;
task_wakeup(s->task, TASK_WOKEN_RES); task_wakeup(s->task, TASK_WOKEN_RES);
return 1; return 1;
@ -748,8 +749,10 @@ void stream_free(struct stream *s)
*/ */
static int stream_alloc_work_buffer(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; return 1;
}
b_requeue(DB_CHANNEL, &s->buffer_wait); b_requeue(DB_CHANNEL, &s->buffer_wait);
return 0; return 0;