aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-09 00:02:33 +0000
committertv <tv@krebsco.de>2026-11-09 01:05:41 +0100
commit8e5dda246c4684908613178034014e79537ebfc2 (patch)
treed20f8af42ee318a6a9e2cb1e5773e438b4d0fd13 /src/transport
parent51e08cdc8d90c71b841f12089adb3518340f51e1 (diff)
dashboard: messages as they come
The node sent its messages to the page every 2 s (`messages` events, this node's and a subscribed node's), and this node's ran on the map from its counts, which come with the state: the map showed a message 2 to 4 s after it went, the messages of each 2 s spread evenly over the next. The message log now tells those waiting of each message logged (MessageLog::logged_after), and both streams send what was logged a tenth of a second after the first of it (MESSAGES_GATHERED): a busy node about ten events a second, a quiet one each message soon after it went. The page runs messages as their streams bring them, this node's from its own log too (with the addresses its PINGs went to), as far apart as they were sent; more than six on a link and way at once are shared out by kind over the moment, and after a gap only the last 2 s run. The counts still give the rates and what was delivered.
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/traffic.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/transport/traffic.rs b/src/transport/traffic.rs
index b9506a9..948e5d5 100644
--- a/src/transport/traffic.rs
+++ b/src/transport/traffic.rs
@@ -158,6 +158,8 @@ const LOGGED_TEXT: usize = 8 * 1024;
pub(crate) struct MessageLog {
/// How many look (`watch`).
watching: AtomicUsize,
+ /// Told of each message logged, for those sending them on as they come (`logged`).
+ logged: tokio::sync::Notify,
inner: Mutex<LogInner>,
}
@@ -293,6 +295,18 @@ impl MessageLog {
if inner.entries.len() > LOGGED {
inner.entries.pop_front();
}
+ drop(inner);
+ self.logged.notify_waiters();
+ }
+
+ /// Until a message after `seq` is logged: at once if one is. Blocking nothing.
+ pub(crate) async fn logged_after(&self, seq: u64) {
+ // Made before looking, so a message logged in between still wakes it.
+ let logged = self.logged.notified();
+ if self.latest() > seq {
+ return;
+ }
+ logged.await;
}
/// The messages after `seq`, the latest `most` of them.