MINOR: dynbuf: pass offer_buffers() the number of buffers instead of a threshold
Historically this function would try to wake the most accurate number of
process_stream() waiters. But since the introduction of filters which could
also require buffers (e.g. for compression), things started not to be as
accurate anymore. Nowadays muxes and transport layers also use buffers, so
the runqueue size has nothing to do anymore with the number of supposed
users to come.
In addition to this, the threshold was compared to the number of free buffer
calculated as allocated minus used, but this didn't work anymore with local
pools since these counts are not updated upon alloc/free!
Let's clean this up and pass the number of released buffers instead, and
consider that each waiter successfully called counts as one buffer. This
is not rocket science and will not suddenly fix everything, but at least
it cannot be as wrong as it is today.
This could have been marked as a bug given that the current situation is
totally broken regarding this, but this probably doesn't completely fix
it, it only goes in a better direction. It is possible however that it
makes sense in the future to backport this as part of a larger series if
the situation significantly improves.
(cherry picked from commit 4d77bbf8560b5d5b32409be131e4975811bfec28)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/src/stream.c b/src/stream.c
index 6fca1d1..411849c 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -598,9 +598,11 @@
LIST_DEL_INIT(&s->buffer_wait.list);
if (s->req.buf.size || s->res.buf.size) {
+ int count = !!s->req.buf.size + !!s->res.buf.size;
+
b_free(&s->req.buf);
b_free(&s->res.buf);
- offer_buffers(NULL, tasks_run_queue);
+ offer_buffers(NULL, count);
}
pool_free(pool_head_uniqueid, s->unique_id.ptr);
@@ -748,11 +750,11 @@
int offer = 0;
if (c_size(&s->req) && c_empty(&s->req)) {
- offer = 1;
+ offer++;
b_free(&s->req.buf);
}
if (c_size(&s->res) && c_empty(&s->res)) {
- offer = 1;
+ offer++;
b_free(&s->res.buf);
}
@@ -760,7 +762,7 @@
* someone waiting, we can wake up a waiter and offer them.
*/
if (offer)
- offer_buffers(s, tasks_run_queue);
+ offer_buffers(s, offer);
}
void stream_process_counters(struct stream *s)