Skip to content

Commit afeac4b

Browse files
committed
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.
1 parent d7c34ba commit afeac4b

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

include/haproxy/debug.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ struct buffer;
2727
extern unsigned int debug_commands_issued;
2828
void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx);
2929
void ha_thread_dump_one(int thr, int from_signal);
30-
void ha_thread_dump(struct buffer *buf, int thr);
3130
void ha_dump_backtrace(struct buffer *buf, const char *prefix, int dump);
3231
void ha_backtrace_to_stderr(void);
3332
void ha_panic(void);

src/debug.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -416,15 +416,6 @@ void ha_thread_dump_done(struct buffer *buf, int thr)
416416
} while (!HA_ATOMIC_CAS(&ha_thread_ctx[thr].thread_dump_buffer, &old, buf));
417417
}
418418

419-
/* performs a complete thread dump: calls the remote thread and marks the
420-
* buffer as read.
421-
*/
422-
void ha_thread_dump(struct buffer *buf, int thr)
423-
{
424-
ha_thread_dump_fill(buf, thr);
425-
ha_thread_dump_done(NULL, thr);
426-
}
427-
428419
/* dumps into the buffer some information related to task <task> (which may
429420
* either be a task or a tasklet, and prepend each line except the first one
430421
* 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)
519510

520511
do {
521512
chunk_reset(&trash);
522-
ha_thread_dump(&trash, *thr);
523-
524-
if (applet_putchk(appctx, &trash) == -1) {
525-
/* failed, try again */
526-
return 0;
513+
if (ha_thread_dump_fill(&trash, *thr)) {
514+
ha_thread_dump_done(NULL, *thr);
515+
if (applet_putchk(appctx, &trash) == -1) {
516+
/* failed, try again */
517+
return 0;
518+
}
527519
}
528520
(*thr)++;
529521
} while (*thr < global.nbthread);
@@ -686,8 +678,10 @@ void ha_panic()
686678
chunk_appendf(&trash, "Thread %u is about to kill the process.\n", tid + 1);
687679

688680
for (thr = 0; thr < global.nbthread; thr++) {
689-
ha_thread_dump(&trash, thr);
681+
if (!ha_thread_dump_fill(&trash, thr))
682+
continue;
690683
DISGUISE(write(2, trash.area, trash.data));
684+
ha_thread_dump_done(NULL, thr);
691685
b_force_xfer(buf, &trash, b_room(buf));
692686
chunk_reset(&trash);
693687
}

0 commit comments

Comments
 (0)