]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: debug: replace ha_thread_dump() with its two components
authorWilly Tarreau <w@1wt.eu>
Sat, 19 Oct 2024 12:15:20 +0000 (14:15 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 19 Oct 2024 13:42:34 +0000 (15:42 +0200)
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.

include/haproxy/debug.h
src/debug.c

index b7a2e2072fe48c2fa3f7fb21c6c870fa4395e03a..f01441c9f71befb2e5ffa00fb1ddfbfae8533a7f 100644 (file)
@@ -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);
index 55b1744baec57699b477db80234c404532304bfe..3395150af227ceb25ed70ce61c6895808d4a8ec8 100644 (file)
@@ -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 <task> (which may
  * either be a task or a tasklet, and prepend each line except the first one
  * with <pfx>. 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);
        }