BUG/MINOR: pools: always flush pools about to be destroyed
authorWilly Tarreau <w@1wt.eu>
Wed, 9 Feb 2022 15:19:24 +0000 (16:19 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 15 Feb 2022 06:35:34 +0000 (07:35 +0100)
commitcc5504f86409b754317bdc2d4dc8e2c554a25549
tree993b1d36f371540f5836dfc689400c8e5c1c36b7
parent84b5fbdc934c4a26d8b87bc75641b24debb93988
BUG/MINOR: pools: always flush pools about to be destroyed

When destroying a pool (e.g. at exit or when resizing buffers), it's
important to try to free all their local objects otherwise we can leave
some in the cache. This is particularly visible when changing "bufsize",
because "show pools" will then show two "trash" pools, one of which
contains a single object in cache (which is fortunately not reachable).
In all cases this happens while single-threaded so that's easy to do,
we just have to do it on the current thread.

The easiest way to do this is to pass an extra argument to function
pool_evict_from_local_cache() to force a full flush instead of a
partial one.

This can probably be backported to about all branches where this
applies, but at least 2.4 needs it.

(cherry picked from commit c895c441c7579db652e4ed976c14c2f5b2de0c0e)
[wt: context adjustments as 2.5 doesn't use pool_evict_last_items()]
Signed-off-by: Willy Tarreau <w@1wt.eu>
include/haproxy/pool.h
src/pool.c