Skip to content

Commit a669830

Browse files
committed
MINOR: chunk: drop the global thread_dump_buffer
This variable is not very useful and is confusing anyway. It was mostly used to detect that a panic dump was still in progress, but we can now check mark_tainted() for this. The pointer was set to one of the dumping thread's trash chunks. Let's temporarily continue to copy the dumps to that trash, we'll remove it later.
1 parent 8e04860 commit a669830

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/debug.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ struct post_mortem {
157157
struct post_mortem_component *components; // NULL or array
158158
} post_mortem ALIGNED(256) = { };
159159

160-
/* Points to a copy of the buffer where the dump functions should write, when
161-
* non-null. It's only used by debuggers for core dump analysis.
162-
*/
163-
struct buffer *thread_dump_buffer = NULL;
164160
unsigned int debug_commands_issued = 0;
165161

166162
/* dumps a backtrace of the current thread that is appended to buffer <buf>.
@@ -631,21 +627,13 @@ static int debug_parse_cli_show_dev(char **args, char *payload, struct appctx *a
631627
return cli_msg(appctx, LOG_INFO, trash.area);
632628
}
633629

634-
/* Dumps a state of all threads into the trash and on fd #2, then aborts.
635-
* A copy will be put into a trash chunk that's assigned to thread_dump_buffer
636-
* so that the debugger can easily find it. This buffer might be truncated if
637-
* too many threads are being dumped, but at least we'll dump them all on stderr.
638-
* If thread_dump_buffer is set, it means that a panic has already begun.
639-
*/
630+
/* Dumps a state of all threads into the trash and on fd #2, then aborts. */
640631
void ha_panic()
641632
{
642-
struct buffer *old;
633+
struct buffer *buf;
643634
unsigned int thr;
644635

645-
mark_tainted(TAINTED_PANIC);
646-
647-
old = NULL;
648-
if (!HA_ATOMIC_CAS(&thread_dump_buffer, &old, get_trash_chunk())) {
636+
if (mark_tainted(TAINTED_PANIC) & TAINTED_PANIC) {
649637
/* a panic dump is already in progress, let's not disturb it,
650638
* we'll be called via signal DEBUGSIG. By returning we may be
651639
* able to leave a current signal handler (e.g. WDT) so that
@@ -654,13 +642,15 @@ void ha_panic()
654642
return;
655643
}
656644

645+
buf = get_trash_chunk();
646+
657647
chunk_reset(&trash);
658648
chunk_appendf(&trash, "Thread %u is about to kill the process.\n", tid + 1);
659649

660650
for (thr = 0; thr < global.nbthread; thr++) {
661651
ha_thread_dump(&trash, thr);
662652
DISGUISE(write(2, trash.area, trash.data));
663-
b_force_xfer(thread_dump_buffer, &trash, b_room(thread_dump_buffer));
653+
b_force_xfer(buf, &trash, b_room(buf));
664654
chunk_reset(&trash);
665655
}
666656

0 commit comments

Comments
 (0)