From c17451ca73caac131fe074c74a5006838a6aeec2 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Tue, 29 Jun 2021 09:29:28 -0700 Subject: [PATCH] Acquire instance read lock once --- gossip/src/cluster_info.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gossip/src/cluster_info.rs b/gossip/src/cluster_info.rs index 105994e63..6e68c53c3 100644 --- a/gossip/src/cluster_info.rs +++ b/gossip/src/cluster_info.rs @@ -2490,11 +2490,12 @@ impl ClusterInfo { .collect() }) }; + // Check if there is a duplicate instance of // this node with more recent timestamp. + let instance = self.instance.read().unwrap(); let check_duplicate_instance = |values: &[CrdsValue]| { if should_check_duplicate_instance { - let instance = self.instance.read().unwrap(); for value in values { if instance.check_duplicate(value) { return Err(GossipError::DuplicateNodeInstance);