From b7a494c40df4fac41e8fc57c8dc768062c57d0df Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 22 Apr 2024 21:00:14 -0700 Subject: [PATCH] reduce tls override cache lock exposure Signed-off-by: Jason Volk --- src/service/globals/resolver.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/service/globals/resolver.rs b/src/service/globals/resolver.rs index 35910f5d..9d52cba2 100644 --- a/src/service/globals/resolver.rs +++ b/src/service/globals/resolver.rs @@ -88,14 +88,12 @@ impl Resolve for Resolver { impl Resolve for Hooked { fn resolve(&self, name: Name) -> Resolving { - self.overrides - .read() - .unwrap() - .get(name.as_str()) - .map_or_else( - || resolve_to_reqwest(self.resolver.clone(), name), - |(override_name, port)| cached_to_reqwest(override_name, *port), - ) + let addr_port = self.overrides.read().unwrap().get(name.as_str()).cloned(); + if let Some((addr, port)) = addr_port { + cached_to_reqwest(&addr, port) + } else { + resolve_to_reqwest(self.resolver.clone(), name) + } } }