mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 22:01:31 +02:00
MINOR: pools: drop the unused static history of artificially failed allocs
When building with DEBUG_FAIL_ALLOC we call a random generator to decide whether the pool alloc should succeed or fail, and there was a preliminary debugging mechanism to keep sort of a history of the previous decisions. But it was never used, enforces a lock during the allocation, and forces to use static variables, all of which are limiting the ability to pursue the pools cleanups with no real benefit. Let's get rid of them now.
This commit is contained in:
parent
a5b229d01d
commit
3e970b11eb
20
src/pool.c
20
src/pool.c
@ -655,16 +655,10 @@ static struct cli_kw_list cli_kws = {{ },{
|
|||||||
INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
|
INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
|
||||||
|
|
||||||
#ifdef DEBUG_FAIL_ALLOC
|
#ifdef DEBUG_FAIL_ALLOC
|
||||||
#define MEM_FAIL_MAX_CHAR 32
|
|
||||||
#define MEM_FAIL_MAX_STR 128
|
|
||||||
static int mem_fail_cur_idx;
|
|
||||||
static char mem_fail_str[MEM_FAIL_MAX_CHAR * MEM_FAIL_MAX_STR];
|
|
||||||
__decl_thread(static HA_SPINLOCK_T mem_fail_lock);
|
|
||||||
|
|
||||||
int mem_should_fail(const struct pool_head *pool)
|
int mem_should_fail(const struct pool_head *pool)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int n;
|
|
||||||
|
|
||||||
if (mem_fail_rate > 0 && !(global.mode & MODE_STARTING)) {
|
if (mem_fail_rate > 0 && !(global.mode & MODE_STARTING)) {
|
||||||
int randnb = ha_random() % 100;
|
int randnb = ha_random() % 100;
|
||||||
@ -674,20 +668,6 @@ int mem_should_fail(const struct pool_head *pool)
|
|||||||
else
|
else
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
HA_SPIN_LOCK(POOL_LOCK, &mem_fail_lock);
|
|
||||||
n = snprintf(&mem_fail_str[mem_fail_cur_idx * MEM_FAIL_MAX_CHAR],
|
|
||||||
MEM_FAIL_MAX_CHAR - 2,
|
|
||||||
"%d %.18s %d %d", mem_fail_cur_idx, pool->name, ret, tid);
|
|
||||||
while (n < MEM_FAIL_MAX_CHAR - 1)
|
|
||||||
mem_fail_str[mem_fail_cur_idx * MEM_FAIL_MAX_CHAR + n++] = ' ';
|
|
||||||
if (mem_fail_cur_idx < MEM_FAIL_MAX_STR - 1)
|
|
||||||
mem_fail_str[mem_fail_cur_idx * MEM_FAIL_MAX_CHAR + n] = '\n';
|
|
||||||
else
|
|
||||||
mem_fail_str[mem_fail_cur_idx * MEM_FAIL_MAX_CHAR + n] = 0;
|
|
||||||
mem_fail_cur_idx++;
|
|
||||||
if (mem_fail_cur_idx == MEM_FAIL_MAX_STR)
|
|
||||||
mem_fail_cur_idx = 0;
|
|
||||||
HA_SPIN_UNLOCK(POOL_LOCK, &mem_fail_lock);
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user