]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: pools: make sure to also destroy shared pools in pool_destroy_all()
authorWilly Tarreau <w@1wt.eu>
Wed, 27 Apr 2022 09:33:13 +0000 (11:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 27 Apr 2022 09:33:13 +0000 (11:33 +0200)
commit243e68b552b1d27dd8f86c35394551c124652ed2
treeb4f704375d277447c1c3d35086fa9db96dbf5b54
parent974358954bb4d02f713d29fa5f5f25affe52a158
BUG/MINOR: pools: make sure to also destroy shared pools in pool_destroy_all()

In issue #1677, Tim reported that we don't correctly free some shared
pools on exit. What happens in fact is that pool_destroy() is meant to
be called once per pool *pointer*, as it decrements the use count for
each pass and only releases the pool when it reaches zero. But since
pool_destroy_all() iterates over the pools list, it visits each pool
only once and will not eliminate some of them, which thus remain in the
list.

In an ideal case, the function should loop over all pools for as long
as the list is not empty, but that's pointless as we know we're exiting,
so let's just set the users count to 1 before the call so that
pool_destroy() knows it can delete and release the entry.

This could be backported to all versions (memory.c in 2.0 and older) but
it's not a real problem in practice.
src/pool.c