From 63da80012a5b33ddd927cb19b36b2b1145d68e50 Mon Sep 17 00:00:00 2001 From: Sebastian Holmin Date: Tue, 28 Nov 2023 18:01:46 +0100 Subject: [PATCH] Change to exponential retry delay --- mullvad-daemon/src/geoip.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mullvad-daemon/src/geoip.rs b/mullvad-daemon/src/geoip.rs index 02ee09d1c0d7..0af495e8bd83 100644 --- a/mullvad-daemon/src/geoip.rs +++ b/mullvad-daemon/src/geoip.rs @@ -8,12 +8,9 @@ use mullvad_api::{ }; use mullvad_types::location::{AmIMullvad, GeoIpLocation}; use once_cell::sync::Lazy; -use talpid_core::future_retry::{retry_future, ConstantInterval}; +use talpid_core::future_retry::{retry_future, ExponentialBackoff, Jittered}; use talpid_types::ErrorExt; -/// Retry interval for fetching location -const RETRY_LOCATION_STRATEGY: ConstantInterval = ConstantInterval::new(Duration::ZERO, Some(3)); - // Define the Mullvad connection checking api endpoint. // // In a development build the host name for the connection checking endpoint can @@ -43,6 +40,9 @@ static MULLVAD_CONNCHECK_HOST: Lazy = Lazy::new(|| { host.to_string() }); +const LOCATION_RETRY_STRATEGY: Jittered = + Jittered::jitter(ExponentialBackoff::new(Duration::from_secs(1), 4)); + /// Fetch the current `GeoIpLocation` with retrys pub async fn get_geo_location( rest_service: RequestServiceHandle, @@ -56,7 +56,7 @@ pub async fn get_geo_location( Err(error) if error.is_network_error() => !api_handle.get_state().is_offline(), _ => false, }, - RETRY_LOCATION_STRATEGY, + LOCATION_RETRY_STRATEGY, ) .await {