Add more locks
This commit is contained in:
@@ -74,7 +74,7 @@ class Routing(val downstream: String, ownerAddress: InterfaceAddress? = null) {
|
|||||||
var subrouting: Subrouting? = null
|
var subrouting: Subrouting? = null
|
||||||
var dns: List<InetAddress> = emptyList()
|
var dns: List<InetAddress> = emptyList()
|
||||||
|
|
||||||
override fun onAvailable(ifname: String, dns: List<InetAddress>) {
|
override fun onAvailable(ifname: String, dns: List<InetAddress>) = synchronized(this@Routing) {
|
||||||
if (!upstreams.add(ifname)) return
|
if (!upstreams.add(ifname)) return
|
||||||
val subrouting = subrouting
|
val subrouting = subrouting
|
||||||
if (subrouting == null) this.subrouting = try {
|
if (subrouting == null) this.subrouting = try {
|
||||||
@@ -88,7 +88,7 @@ class Routing(val downstream: String, ownerAddress: InterfaceAddress? = null) {
|
|||||||
updateDnsRoute()
|
updateDnsRoute()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLost() {
|
override fun onLost() = synchronized(this@Routing) {
|
||||||
val subrouting = subrouting ?: return
|
val subrouting = subrouting ?: return
|
||||||
check(upstreams.remove(subrouting.upstream))
|
check(upstreams.remove(subrouting.upstream))
|
||||||
subrouting.close()
|
subrouting.close()
|
||||||
@@ -100,7 +100,7 @@ class Routing(val downstream: String, ownerAddress: InterfaceAddress? = null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private val fallbackUpstream = object : Upstream(RULE_PRIORITY_UPSTREAM_FALLBACK) {
|
private val fallbackUpstream = object : Upstream(RULE_PRIORITY_UPSTREAM_FALLBACK) {
|
||||||
override fun onFallback() {
|
override fun onFallback() = synchronized(this@Routing) {
|
||||||
check(subrouting == null)
|
check(subrouting == null)
|
||||||
subrouting = try {
|
subrouting = try {
|
||||||
Subrouting(this@Routing, priority)
|
Subrouting(this@Routing, priority)
|
||||||
|
|||||||
Reference in New Issue
Block a user