diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2021-03-25 14:59:19 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2021-03-25 18:19:59 +0000 |
| commit | 9d537ce034c0a3dfc9d73491d4803fa9dc290737 (patch) | |
| tree | 5ec658ef119c33781552f7c1ee18813d63e8625a /android | |
| parent | dcf2f90639f69fc595a8b99502d3567b5708831b (diff) | |
| download | mullvadvpn-9d537ce034c0a3dfc9d73491d4803fa9dc290737.tar.xz mullvadvpn-9d537ce034c0a3dfc9d73491d4803fa9dc290737.zip | |
Move `delays` to be a `fetchRetryDelays` property
Diffstat (limited to 'android')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/LocationInfoCache.kt | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/LocationInfoCache.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/LocationInfoCache.kt index ad35039b16..5b0f613d0f 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/LocationInfoCache.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/LocationInfoCache.kt @@ -27,6 +27,12 @@ class LocationInfoCache(private val endpoint: ServiceEndpoint) { } } + private val fetchRetryDelays = ExponentialBackoff().apply { + scale = 50 + cap = 30 /* min */ * 60 /* s */ * 1000 /* ms */ + count = 17 // ceil(log2(cap / scale) + 1) + } + private val fetchRequestChannel = runFetcher() private val daemon @@ -94,23 +100,17 @@ class LocationInfoCache(private val endpoint: ServiceEndpoint) { } private suspend fun fetcherLoop(channel: ReceiveChannel<RequestFetch>) { - val delays = ExponentialBackoff().apply { - scale = 50 - cap = 30 /* min */ * 60 /* s */ * 1000 /* ms */ - count = 17 // ceil(log2(cap / scale) + 1) - } - while (true) { var fetchType = channel.receive() var newLocation = daemon.await().getCurrentLocation() while (newLocation == null || !channel.isEmpty) { - fetchType = delayOrReceive(delays, channel, fetchType) + fetchType = delayOrReceive(fetchRetryDelays, channel, fetchType) newLocation = daemon.await().getCurrentLocation() } handleNewLocation(newLocation, fetchType) - delays.reset() + fetchRetryDelays.reset() } } |
