From: Willy Tarreau Date: Sat, 19 Oct 2024 12:15:20 +0000 (+0200) Subject: MINOR: debug: replace ha_thread_dump() with its two components X-Git-Tag: v3.1-dev11~98 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=afeac4bc026e64e27d99e50480bff5bc1ee60cb9;p=thirdparty%2Fhaproxy.git MINOR: debug: replace ha_thread_dump() with its two components At the few places we were calling ha_thread_dump(), now we're calling separately ha_thread_dump_fill() and ha_thread_dump_done() once the data are consumed. --- diff --git a/include/haproxy/debug.h b/include/haproxy/debug.h index b7a2e2072f..f01441c9f7 100644 --- a/include/haproxy/debug.h +++ b/include/haproxy/debug.h @@ -27,7 +27,6 @@ struct buffer; extern unsigned int debug_commands_issued; void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx); void ha_thread_dump_one(int thr, int from_signal); -void ha_thread_dump(struct buffer *buf, int thr); void ha_dump_backtrace(struct buffer *buf, const char *prefix, int dump); void ha_backtrace_to_stderr(void); void ha_panic(void); diff --git a/src/debug.c b/src/debug.c index 55b1744bae..3395150af2 100644 --- a/src/debug.c +++ b/src/debug.c @@ -416,15 +416,6 @@ void ha_thread_dump_done(struct buffer *buf, int thr) } while (!HA_ATOMIC_CAS(&ha_thread_ctx[thr].thread_dump_buffer, &old, buf)); } -/* performs a complete thread dump: calls the remote thread and marks the - * buffer as read. - */ -void ha_thread_dump(struct buffer *buf, int thr) -{ - ha_thread_dump_fill(buf, thr); - ha_thread_dump_done(NULL, thr); -} - /* dumps into the buffer some information related to task (which may * either be a task or a tasklet, and prepend each line except the first one * with . The buffer is only appended and the first output starts by the @@ -519,11 +510,12 @@ static int cli_io_handler_show_threads(struct appctx *appctx) do { chunk_reset(&trash); - ha_thread_dump(&trash, *thr); - - if (applet_putchk(appctx, &trash) == -1) { - /* failed, try again */ - return 0; + if (ha_thread_dump_fill(&trash, *thr)) { + ha_thread_dump_done(NULL, *thr); + if (applet_putchk(appctx, &trash) == -1) { + /* failed, try again */ + return 0; + } } (*thr)++; } while (*thr < global.nbthread); @@ -686,8 +678,10 @@ void ha_panic() chunk_appendf(&trash, "Thread %u is about to kill the process.\n", tid + 1); for (thr = 0; thr < global.nbthread; thr++) { - ha_thread_dump(&trash, thr); + if (!ha_thread_dump_fill(&trash, thr)) + continue; DISGUISE(write(2, trash.area, trash.data)); + ha_thread_dump_done(NULL, thr); b_force_xfer(buf, &trash, b_room(buf)); chunk_reset(&trash); }