common/msg_queue: send backtrace on oversize queues.

Scary looking, but great for debugging!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2024-10-28 20:25:50 +10:30
parent 1051e97d69
commit 1e4adbff17
14 changed files with 58 additions and 2 deletions

View File

@@ -2,10 +2,13 @@
#include <assert.h>
#include <ccan/cast/cast.h>
#include <ccan/membuf/membuf.h>
#include <common/daemon.h>
#include <common/msg_queue.h>
#include <common/utils.h>
#include <wire/wire.h>
static bool warned_once;
struct msg_queue {
bool fd_passing;
MEMBUF(const u8 *) mb;
@@ -60,6 +63,12 @@ static void do_enqueue(struct msg_queue *q, const u8 *add TAKES)
*msg = tal_dup_talarr(q, u8, add);
if (!warned_once && msg_queue_length(q) > 100000) {
/* Can cause re-entry, so set flag first! */
warned_once = true;
send_backtrace("excessive queue length");
}
/* In case someone is waiting */
io_wake(q);
}