From: Willy Tarreau Date: Thu, 15 Apr 2021 14:36:07 +0000 (+0200) Subject: MINOR: pools: drop the unused static history of artificially failed allocs X-Git-Tag: v2.4-dev17~82 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3e970b11ebc402ef6e23c50794db823143e0c526;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/pool.c b/src/pool.c index 0227f36690..cdb3eefe4d 100644 --- a/src/pool.c +++ b/src/pool.c @@ -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; }