From 2b99e830fd47795e9ae8cdc1a0eb91deadaf4cdd Mon Sep 17 00:00:00 2001 From: Herr Seppia Date: Wed, 2 Oct 2024 17:03:18 +0200 Subject: [PATCH] Add warning when discarding incomplete messages --- CHANGELOG.md | 1 + src/transport/encoding/raptorq/decoder.rs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8117c44..971e4ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add range checks to MTU (between 1296 and 8192) - Add network version to handshake messages - Add Ray-ID to MessageInfo for message tracking +- Add warning when discarding incomplete messages ### Fixed diff --git a/src/transport/encoding/raptorq/decoder.rs b/src/transport/encoding/raptorq/decoder.rs index 4250861..e1d589b 100644 --- a/src/transport/encoding/raptorq/decoder.rs +++ b/src/transport/encoding/raptorq/decoder.rs @@ -69,6 +69,10 @@ enum CacheStatus { } impl CacheStatus { + fn receiving(&self) -> bool { + matches!(&self, CacheStatus::Receiving(..)) + } + fn expired(&self) -> bool { let expire_on = match self { CacheStatus::Receiving(_, expire_on, _, _) => expire_on, @@ -183,7 +187,16 @@ impl Decoder for RaptorQDecoder { }; // Every X time, prune dupemap cache if self.last_pruned.elapsed() > self.conf.cache_prune_every { - self.cache.retain(|_, status| !status.expired()); + self.cache.retain(|ray_id, status| { + let keep = !status.expired(); + if !keep && status.receiving() { + warn!( + event = "dupemap discard", + ray = hex::encode(ray_id) + ); + }; + keep + }); self.last_pruned = Instant::now(); } Ok(decoded)