From: Willy Tarreau Date: Mon, 29 Apr 2024 06:52:40 +0000 (+0200) Subject: MEDIUM: dynbuf/stream: re-enable queueing upon failed buffer allocation X-Git-Tag: v3.0-dev11~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=db21062881686ab04ee32e1af197f25e72719d69;p=thirdparty%2Fhaproxy.git MEDIUM: dynbuf/stream: re-enable queueing upon failed buffer allocation The errors were not working fine anyway since we know that upon low memory condition everything freezes. However we have a chance to do better now, so let's start by re-enabling queueing when allocations fail. --- diff --git a/src/stream.c b/src/stream.c index a50294251f..a91cbe4a5c 100644 --- a/src/stream.c +++ b/src/stream.c @@ -753,6 +753,8 @@ static int stream_alloc_work_buffer(struct stream *s) { if (b_alloc(&s->res.buf, DB_CHANNEL)) return 1; + + b_requeue(DB_CHANNEL, &s->buffer_wait); return 0; } @@ -1793,25 +1795,12 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) } resync_stconns: - /* below we may emit error messages so we have to ensure that we have - * our buffers properly allocated. If the allocation failed, an error is - * triggered. - * - * NOTE: An error is returned because the mechanism to queue entities - * waiting for a buffer is totally broken for now. However, this - * part must be refactored. When it will be handled, this part - * must be be reviewed too. - */ if (!stream_alloc_work_buffer(s)) { - scf->flags |= SC_FL_ERROR; - s->conn_err_type = STRM_ET_CONN_RES; - - scb->flags |= SC_FL_ERROR; - s->conn_err_type = STRM_ET_CONN_RES; - - if (!(s->flags & SF_ERR_MASK)) - s->flags |= SF_ERR_RESOURCE; - sess_set_term_flags(s); + scf->flags &= ~SC_FL_DONT_WAKE; + scb->flags &= ~SC_FL_DONT_WAKE; + /* we're stuck for now */ + t->expire = TICK_ETERNITY; + goto leave; } /* 1b: check for low-level errors reported at the stream connector. @@ -2551,7 +2540,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) stream_handle_timeouts(s); goto resync_stconns; } - + leave: s->pending_events &= ~(TASK_WOKEN_TIMER | TASK_WOKEN_RES); stream_release_buffers(s);