From 4fea3a60d6804c862006d6d1416b130172d54442 Mon Sep 17 00:00:00 2001 From: "Sijie.Sun" Date: Fri, 2 Aug 2024 00:48:31 +0800 Subject: [PATCH] update last_updated of peer info to local now (#211) time between peers may not be synced, using peer last_updated time may cause peer info being cleared incorrectly --- Cargo.lock | 11 +++++++++++ easytier/src/peers/peer_ospf_route.rs | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 07ad3cf..41a1d84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1426,6 +1426,7 @@ dependencies = [ "url", "uuid", "windows-sys 0.52.0", + "winreg 0.11.0", "zerocopy", "zip", ] @@ -7175,6 +7176,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "winreg" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a1a57ff50e9b408431e8f97d5456f2807f8eb2a2cd79b06068fc87f8ecf189" +dependencies = [ + "cfg-if", + "winapi", +] + [[package]] name = "winreg" version = "0.50.0" diff --git a/easytier/src/peers/peer_ospf_route.rs b/easytier/src/peers/peer_ospf_route.rs index e48145a..1dc0684 100644 --- a/easytier/src/peers/peer_ospf_route.rs +++ b/easytier/src/peers/peer_ospf_route.rs @@ -291,7 +291,11 @@ impl SyncedRouteInfo { peer_infos: &Vec, ) -> Result<(), Error> { self.check_duplicate_peer_id(my_peer_id, dst_peer_id, peer_infos)?; - for route_info in peer_infos.iter() { + for mut route_info in peer_infos.iter().map(Clone::clone) { + // time between peers may not be synchronized, so update last_update to local now. + // note only last_update with larger version will be updated to local saved peer info. + route_info.last_update = SystemTime::now(); + self.peer_infos .entry(route_info.peer_id) .and_modify(|old_entry| {