Skip to content

Commit 5819e29

Browse files
authored
android: make close() idempotent (#756)
If the VPN is revoked, close is called twice, resulting in the state being forced into Stopping after setWantRunning=true is issued Updates tailscale/tailscale#18847 Signed-off-by: kari-ts <kari@tailscale.com>
1 parent e118bbd commit 5819e29

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

android/src/main/java/com/tailscale/ipn/IPNService.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ open class IPNService : VpnService(), libtailscale.IPNService {
2424
private val randomID: String = UUID.randomUUID().toString()
2525
private lateinit var app: App
2626
val scope = CoroutineScope(Dispatchers.IO)
27+
private var closed = false
2728

2829
override fun id(): String {
2930
return randomID
@@ -96,6 +97,8 @@ open class IPNService : VpnService(), libtailscale.IPNService {
9697
}
9798

9899
override fun close() {
100+
if (closed) return
101+
closed = true
99102
Notifier.setState(Ipn.State.Stopping)
100103
disconnectVPN()
101104
Libtailscale.serviceDisconnect(this)

0 commit comments

Comments
 (0)