mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 16:47:18 +02:00
BUG/MEDIUM: memory_pool: Update the seq number in pool_flush().
In pool_flush(), we can't just set the free_list to NULL, or we may suffer the ABA problem. Instead, use a double-width CAS and update the sequence number. This should be backported to 2.1, 2.0 and 1.9. This may, or may not, be related to github issue #476.
This commit is contained in:
parent
952c2640b0
commit
b6fa08bc7b
@ -217,15 +217,20 @@ void *pool_refill_alloc(struct pool_head *pool, unsigned int avail)
|
|||||||
*/
|
*/
|
||||||
void pool_flush(struct pool_head *pool)
|
void pool_flush(struct pool_head *pool)
|
||||||
{
|
{
|
||||||
|
struct pool_free_list cmp, new;
|
||||||
void **next, *temp;
|
void **next, *temp;
|
||||||
int removed = 0;
|
int removed = 0;
|
||||||
|
|
||||||
if (!pool)
|
if (!pool)
|
||||||
return;
|
return;
|
||||||
do {
|
do {
|
||||||
next = pool->free_list;
|
cmp.free_list = pool->free_list;
|
||||||
} while (!_HA_ATOMIC_CAS(&pool->free_list, &next, NULL));
|
cmp.seq = pool->seq;
|
||||||
|
new.free_list = NULL;
|
||||||
|
new.seq = cmp.seq + 1;
|
||||||
|
} while (!_HA_ATOMIC_DWCAS(&pool->free_list, &cmp, &new));
|
||||||
__ha_barrier_atomic_store();
|
__ha_barrier_atomic_store();
|
||||||
|
next = cmp.free_list;
|
||||||
while (next) {
|
while (next) {
|
||||||
temp = next;
|
temp = next;
|
||||||
next = *POOL_LINK(pool, temp);
|
next = *POOL_LINK(pool, temp);
|
||||||
|
Loading…
Reference in New Issue
Block a user