]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: debug: only dump/reset glitch counters when really defined
authorWilly Tarreau <w@1wt.eu>
Mon, 16 Dec 2024 08:31:27 +0000 (09:31 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 17 Dec 2024 15:46:25 +0000 (16:46 +0100)
If neither DEBUG_GLITCHES nor DEBUG_STRICT is set, we end up with
no dbg_cnt section, resulting in debug_parse_cli_counters not
building due to __stop_dbg_cnt and __start_dbg_cnt not being defined.
Let's just condition the end of the function to these conditions.
An alternate approach (less elegant) is to always declare a dummy
entry of type DBG_COUNTER_TYPES in debug.c.

This must be backported to 3.1 since it was brought with glitches.

src/debug.c

index d052f5b639f01a1e6b81ae6d55be1e7e49d27fd2..cb33cf0b28b69c61e0de88488f7986d08370284e 100644 (file)
@@ -2261,13 +2261,17 @@ static int debug_parse_cli_counters(char **args, char *payload, struct appctx *a
                        return cli_err(appctx, "Expects an optional action ('reset','show'), optional types ('bug','chk','cnt','glt') and optionally 'all' to even dump null counters.\n");
        }
 
+#if DEBUG_STRICT > 0 || defined(DEBUG_GLITCHES)
+       ctx->start = &__start_dbg_cnt;
+       ctx->stop  = &__stop_dbg_cnt;
+#endif
        if (action == 1) { // reset
                struct debug_count *ptr;
 
                if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
                        return 1;
 
-               for (ptr = &__start_dbg_cnt; ptr < &__stop_dbg_cnt; ptr++) {
+               for (ptr = ctx->start; ptr < ctx->stop; ptr++) {
                        if (ctx->types && !(ctx->types & (1 << ptr->type)))
                                continue;
                        _HA_ATOMIC_STORE(&ptr->count, 0);
@@ -2276,8 +2280,6 @@ static int debug_parse_cli_counters(char **args, char *payload, struct appctx *a
        }
 
        /* OK it's a show, let's dump relevant counters */
-       ctx->start = &__start_dbg_cnt;
-       ctx->stop  = &__stop_dbg_cnt;
        return 0;
 }