mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-01 22:48:25 +00:00
[MEDIUM] ensure we don't recursively call pool_gc2()
A race condition exists in the hot reconfiguration code. It is theorically possible that the second signal is sent during a free() in the first list, which can cause crashes or freezes (the later have been observed). Just set up a counter to ensure we do not recurse.
This commit is contained in:
parent
3b88d441e9
commit
b7f9d126e2
10
src/memory.c
10
src/memory.c
@ -122,11 +122,17 @@ void pool_flush2(struct pool_head *pool)
|
||||
|
||||
/*
|
||||
* This function frees whatever can be freed in all pools, but respecting
|
||||
* the minimum thresholds imposed by owners.
|
||||
* the minimum thresholds imposed by owners. It takes care of avoiding
|
||||
* recursion because it may be called from a signal handler.
|
||||
*/
|
||||
void pool_gc2()
|
||||
{
|
||||
static int recurse;
|
||||
struct pool_head *entry;
|
||||
|
||||
if (recurse++)
|
||||
goto out;
|
||||
|
||||
list_for_each_entry(entry, &pools, list) {
|
||||
void *temp, *next;
|
||||
//qfprintf(stderr, "Flushing pool %s\n", entry->name);
|
||||
@ -141,6 +147,8 @@ void pool_gc2()
|
||||
}
|
||||
entry->free_list = next;
|
||||
}
|
||||
out:
|
||||
recurse--;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user