summaryrefslogtreecommitdiffhomepage
path: root/android/src/main
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-03-27 01:54:49 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-03-27 17:28:47 +0000
commit2c2d9d720bba0d45277df4fc7519d4164f934c56 (patch)
treeddd0275a138a8763c720223a8b445ad259e4ac0c /android/src/main
parent16511e76d2e4b415532b095a54d12cb3f31eb268 (diff)
downloadmullvadvpn-2c2d9d720bba0d45277df4fc7519d4164f934c56.tar.xz
mullvadvpn-2c2d9d720bba0d45277df4fc7519d4164f934c56.zip
Make sure location is updated atomically
Diffstat (limited to 'android/src/main')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/service/LocationInfoCache.kt10
1 files changed, 6 insertions, 4 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/LocationInfoCache.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/LocationInfoCache.kt
index 54114bc464..6d6c1e6359 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/LocationInfoCache.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/LocationInfoCache.kt
@@ -153,11 +153,13 @@ class LocationInfoCache(
newLocation = executeFetch().await()
}
- if (newLocation != null && fetchId == fetchIdCounter) {
- location = newLocation
+ synchronized(this@LocationInfoCache) {
+ if (newLocation != null && fetchId == fetchIdCounter) {
+ location = newLocation
- if (isRealLocation) {
- lastKnownRealLocation = newLocation
+ if (isRealLocation) {
+ lastKnownRealLocation = newLocation
+ }
}
}
}