From ec907e204d65109ae13b19f5a5b9ca09029972f7 Mon Sep 17 00:00:00 2001 From: Mygod Date: Sun, 30 Dec 2018 14:03:37 +0800 Subject: [PATCH] Ensure record is unregistered if registering fails --- mobile/src/main/java/be/mygod/vpnhotspot/net/Subrouting.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/Subrouting.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/Subrouting.kt index 25598b8f..85b0fe02 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/Subrouting.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/Subrouting.kt @@ -35,7 +35,12 @@ class Subrouting(private val parent: Routing, priority: Int, val upstream: Strin } init { - TrafficRecorder.register(ip, upstream, parent.downstream, mac) + try { + TrafficRecorder.register(ip, upstream, parent.downstream, mac) + } catch (e: Exception) { + close() + throw e + } } override fun close() {