From 5e086c81dcca18a866413bde5a09e3d46fba76ef Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Sat, 9 Mar 2024 12:50:30 +0100 Subject: [PATCH] warn if state writing takes unusually long --- readsb.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/readsb.c b/readsb.c index 141b34e6..8a3c6ca4 100644 --- a/readsb.c +++ b/readsb.c @@ -2345,9 +2345,20 @@ static void miscStuff(int64_t now) { // only continuously write state if we keep permanent trace if (!Modes.state_only_on_exit && now > next_blob) { //fprintf(stderr, "save_blob: %02x\n", blob); + int64_t blob_interval = Modes.state_write_interval / STATE_BLOBS; + next_blob = now + blob_interval; + + struct timespec watch; + startWatch(&watch); + notask_save_blob(blob); + + int64_t elapsed = stopWatch(&watch); + if (elapsed > 0.5 * SECONDS || elapsed > blob_interval) { + fprintf(stderr, "WARN: save_blob %02x took %"PRIu64" ms!\n", blob, elapsed); + } + blob = (blob + 1) % STATE_BLOBS; - next_blob = now + Modes.state_write_interval / STATE_BLOBS; return; } }