DEBUG: cli: make it possible for "debug dev loop" to trigger warnings

A new argument "warn" allows to force the emission of a warning while
stuck in the loop by making the internal state inconsistent.

(cherry picked from commit 7337c422247b7af342048cfd48ac0aa2a4b7335e)
[wt: backported only to help testing the watchdog backports]
Signed-off-by: Willy Tarreau <w@1wt.eu>
This commit is contained in:
Willy Tarreau 2024-11-06 11:47:55 +01:00
parent a44922fb10
commit 650f633d44

View File

@ -904,11 +904,13 @@ static int debug_parse_cli_loop(char **args, char *payload, struct appctx *appct
struct timeval deadline, curr;
int loop = atoi(args[3]);
int isolate;
int warn;
if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
return 1;
isolate = strcmp(args[4], "isolated") == 0;
warn = strcmp(args[4], "warn") == 0;
_HA_ATOMIC_INC(&debug_commands_issued);
gettimeofday(&curr, NULL);
@ -917,8 +919,11 @@ static int debug_parse_cli_loop(char **args, char *payload, struct appctx *appct
if (isolate)
thread_isolate();
while (tv_ms_cmp(&curr, &deadline) < 0)
while (tv_ms_cmp(&curr, &deadline) < 0) {
if (warn)
_HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_STUCK);
gettimeofday(&curr, NULL);
}
if (isolate)
thread_release();
@ -2537,7 +2542,7 @@ static struct cli_kw_list cli_kws = {{ },{
{{ "debug", "dev", "hash", NULL }, "debug dev hash [msg] : return msg hashed if anon is set", debug_parse_cli_hash, NULL, NULL, NULL, 0 },
{{ "debug", "dev", "hex", NULL }, "debug dev hex <addr> [len] : dump a memory area", debug_parse_cli_hex, NULL, NULL, NULL, ACCESS_EXPERT },
{{ "debug", "dev", "log", NULL }, "debug dev log [msg] ... : send this msg to global logs", debug_parse_cli_log, NULL, NULL, NULL, ACCESS_EXPERT },
{{ "debug", "dev", "loop", NULL }, "debug dev loop <ms> [isolated] : loop this long, possibly isolated", debug_parse_cli_loop, NULL, NULL, NULL, ACCESS_EXPERT },
{{ "debug", "dev", "loop", NULL }, "debug dev loop <ms> [isolated|warn] : loop this long, possibly isolated", debug_parse_cli_loop, NULL, NULL, NULL, ACCESS_EXPERT },
#if defined(DEBUG_MEM_STATS)
{{ "debug", "dev", "memstats", NULL }, "debug dev memstats [reset|all|match ...]: dump/reset memory statistics", debug_parse_cli_memstats, debug_iohandler_memstats, debug_release_memstats, NULL, 0 },
#endif