From 50a6c01e93804b97b91c08967fdb43a3a489cc6c Mon Sep 17 00:00:00 2001 From: Dennis Schwerdel Date: Mon, 20 Dec 2021 08:50:12 +0100 Subject: [PATCH] Fix repeating broadcasts --- CHANGELOG.md | 1 + src/table.rs | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae8de9c..eb0b23c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This project follows [semantic versioning](http://semver.org). - [changed] Changed Rust version to 1.57.0 - [changed] Updated dependencies - [fixed] Fixed problem with IPv4 addresses in listen option +- [fixed] Fixed periodic broadcast messages in switch mode ### v2.2.0 (2021-04-06) diff --git a/src/table.rs b/src/table.rs index fd0888d..f91aece 100644 --- a/src/table.rs +++ b/src/table.rs @@ -48,6 +48,7 @@ impl ClaimTable { } pub fn set_claims(&mut self, peer: SocketAddr, mut claims: RangeList) { + let mut removed_claim = false; for entry in &mut self.claims { if entry.peer == peer { let pos = claims.iter().position(|r| r == &entry.claim); @@ -58,16 +59,19 @@ impl ClaimTable { break; } } else { - entry.timeout = 0 + entry.timeout = 0; + removed_claim = true; } } } for claim in claims { self.claims.push(ClaimEntry { peer, claim, timeout: TS::now() + self.claim_timeout as Time }) } - for entry in self.cache.values_mut() { - if entry.peer == peer { - entry.timeout = 0 + if removed_claim { + for entry in self.cache.values_mut() { + if entry.peer == peer { + entry.timeout = 0 + } } } self.housekeep()