From 255cfac486bdfc3d4ebec2fe03152b986a3eb9c2 Mon Sep 17 00:00:00 2001 From: Mygod Date: Fri, 5 Oct 2018 00:45:53 +0800 Subject: [PATCH] Add more locks --- mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt index 762a2064..ee0033ea 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt @@ -74,7 +74,7 @@ class Routing(val downstream: String, ownerAddress: InterfaceAddress? = null) { var subrouting: Subrouting? = null var dns: List = emptyList() - override fun onAvailable(ifname: String, dns: List) { + override fun onAvailable(ifname: String, dns: List) = synchronized(this@Routing) { if (!upstreams.add(ifname)) return val subrouting = subrouting if (subrouting == null) this.subrouting = try { @@ -88,7 +88,7 @@ class Routing(val downstream: String, ownerAddress: InterfaceAddress? = null) { updateDnsRoute() } - override fun onLost() { + override fun onLost() = synchronized(this@Routing) { val subrouting = subrouting ?: return check(upstreams.remove(subrouting.upstream)) subrouting.close() @@ -100,7 +100,7 @@ class Routing(val downstream: String, ownerAddress: InterfaceAddress? = null) { } } private val fallbackUpstream = object : Upstream(RULE_PRIORITY_UPSTREAM_FALLBACK) { - override fun onFallback() { + override fun onFallback() = synchronized(this@Routing) { check(subrouting == null) subrouting = try { Subrouting(this@Routing, priority)