From: Willy Tarreau Date: Thu, 4 May 2023 09:50:26 +0000 (+0200) Subject: MINOR: debug: permit the "debug dev loop" to run under isolation X-Git-Tag: v2.8-dev10~60 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e5e62231d8c49970aa8758fa28a3ac81e644fcb0;p=thirdparty%2Fhaproxy.git MINOR: debug: permit the "debug dev loop" to run under isolation Sometimes it's convenient to test the effect of tasks running under isolation, e.g. to validate the contents of the crash dumps. Let's add an optional "isolated" keyword to "debug dev loop" for this. --- diff --git a/src/debug.c b/src/debug.c index a53d3491d5..c75e6086b5 100644 --- a/src/debug.c +++ b/src/debug.c @@ -526,17 +526,26 @@ static int debug_parse_cli_loop(char **args, char *payload, struct appctx *appct { struct timeval deadline, curr; int loop = atoi(args[3]); + int isolate; if (!cli_has_level(appctx, ACCESS_LVL_ADMIN)) return 1; + isolate = strcmp(args[4], "isolated") == 0; + _HA_ATOMIC_INC(&debug_commands_issued); gettimeofday(&curr, NULL); tv_ms_add(&deadline, &curr, loop); + if (isolate) + thread_isolate(); + while (tv_ms_cmp(&curr, &deadline) < 0) gettimeofday(&curr, NULL); + if (isolate) + thread_release(); + return 1; } @@ -1860,7 +1869,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 [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] : loop this long", debug_parse_cli_loop, NULL, NULL, NULL, ACCESS_EXPERT }, + {{ "debug", "dev", "loop", NULL }, "debug dev loop [isolated] : 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