MINOR: pools: do not maintain the lock during pool_flush()
authorWilly Tarreau <w@1wt.eu>
Thu, 10 Jun 2021 05:13:04 +0000 (07:13 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 17 Jun 2021 13:56:09 +0000 (15:56 +0200)
commit027eb8b83de984a8c5248a074664826956aa7495
tree9a4417d20c7980f065485ed5a3a97f4337638d16
parentd5c271756d8cd9b6234dfbb6a1d1e09f5b8e89e0
MINOR: pools: do not maintain the lock during pool_flush()

The locked version of pool_flush() is absurd, it locks the pool for each
and every element to be released till the end. Not only this is extremely
inefficient, but it may even never finish if other threads spend their
time refilling the pool. The only case where this can happen is during
soft-stop so the risk remains limited, but it should be addressed.

(cherry picked from commit c88914379da35c46d093f6d410b9507355aacd0a)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit af8120a53cf6a7a8e244135893195c6b65ccc91a)
[wt: in 2.3 the pool_flush code is different because it still requires
 to manipulate ->allocated under the lock, thus the lock covers the
 counting and detaching, and the freeing is performed out of the lock]
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/pool.c