From a5b229d01db53001fc13986ac193379f34eebc72 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 15 Apr 2021 19:24:12 +0200 Subject: [PATCH] BUG/MINOR: pools/buffers: make sure to always reserve the required buffers Since recent commit ae07592 ("MEDIUM: pools: add CONFIG_HAP_NO_GLOBAL_POOLS and CONFIG_HAP_GLOBAL_POOLS") the pre-allocation of all desired reserved buffers was not done anymore on systems not using the shared cache. This basically has no practical impact since these ones will quickly be refilled by all the ones used at run time, but it may confuse someone checking if they're allocated in "show pools". That's only 2.4-dev, no backport is needed. --- src/dynbuf.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/dynbuf.c b/src/dynbuf.c index fcbb8faa4..84e1ca2cd 100644 --- a/src/dynbuf.c +++ b/src/dynbuf.c @@ -27,6 +27,7 @@ int init_buffer() { void *buffer; int thr; + int done; pool_head_buffer = create_pool("buffer", global.tune.bufsize, MEM_F_SHARED|MEM_F_EXACT); if (!pool_head_buffer) @@ -47,11 +48,12 @@ int init_buffer() if (global.tune.buf_limit) pool_head_buffer->limit = global.tune.buf_limit; - buffer = pool_refill_alloc(pool_head_buffer, pool_head_buffer->minavail - 1); - if (!buffer) - return 0; - - pool_free(pool_head_buffer, buffer); + for (done = 0; done < pool_head_buffer->minavail - 1; done++) { + buffer = pool_refill_alloc(pool_head_buffer, 1); + if (!buffer) + return 0; + pool_free(pool_head_buffer, buffer); + } return 1; }