Ensure record is unregistered if registering fails

This commit is contained in:
Mygod
2018-12-30 14:03:37 +08:00
parent ddd3bfab2f
commit ec907e204d

View File

@@ -35,7 +35,12 @@ class Subrouting(private val parent: Routing, priority: Int, val upstream: Strin
} }
init { init {
try {
TrafficRecorder.register(ip, upstream, parent.downstream, mac) TrafficRecorder.register(ip, upstream, parent.downstream, mac)
} catch (e: Exception) {
close()
throw e
}
} }
override fun close() { override fun close() {