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:
Willy Tarreau 2021-04-15 16:36:07 +02:00
parent a5b229d01d
commit 3e970b11eb

View File

@ -655,16 +655,10 @@ static struct cli_kw_list cli_kws = {{ },{
INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
#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 ret = 0;
int n;
if (mem_fail_rate > 0 && !(global.mode & MODE_STARTING)) {
int randnb = ha_random() % 100;
@ -674,20 +668,6 @@ int mem_should_fail(const struct pool_head *pool)
else
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;
}