]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: pools/buffers: make sure to always reserve the required buffers
authorWilly Tarreau <w@1wt.eu>
Thu, 15 Apr 2021 17:24:12 +0000 (19:24 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 19 Apr 2021 13:24:33 +0000 (15:24 +0200)
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

index fcbb8faa4dfef52a3a17899325a34519937b2a6c..84e1ca2cde07bcbecdfcece21b89d1280db87b4e 100644 (file)
@@ -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;
 }