]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pools: drop the unused static history of artificially failed allocs
authorWilly Tarreau <w@1wt.eu>
Thu, 15 Apr 2021 14:36:07 +0000 (16:36 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 19 Apr 2021 13:24:33 +0000 (15:24 +0200)
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.

src/pool.c

index 0227f36690a415d1cd92a17dd4e8feb39f4a9175..cdb3eefe4df8d3faa5e677c2491e5e4bd3137cc9 100644 (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;
 
 }