CLEANUP: pools: use the regular lock for the flush operation on lockless pools
authorWilly Tarreau <w@1wt.eu>
Fri, 29 May 2020 15:23:05 +0000 (17:23 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 29 May 2020 15:28:04 +0000 (17:28 +0200)
commit21072b94806501c26a6e286ed4e46467afd557fe
treeb6750106b3a68daf302abd31cde04e9de84dccde
parent2f44a59c7fdb9e5767bd2d03bb5a2772fb5a8783
CLEANUP: pools: use the regular lock for the flush operation on lockless pools

Commit 04f5fe87d3d introduced an rwlock in the pools to deal with the risk
that pool_flush() dereferences an area being freed, and commit 899fb8abdcd
turned it into a spinlock. The pools already contain a spinlock in case of
locked pools, so let's use the same and simplify the code by removing ifdefs.

At this point I'm really suspecting that if pool_flush() would instead
rely on __pool_get_first() to pick entries from the pool, the concurrency
problem could never happen since only one user would get a given entry at
once, thus it could not be freed by another user. It's not certain this
would be faster however because of the number of atomic ops to retrieve
one entry compared to a locked batch.
include/common/memory.h
src/memory.c