Record stats before exit
This commit is contained in:
@@ -130,6 +130,7 @@ class Routing(private val owner: Context, val upstream: String?, private val dow
|
|||||||
}
|
}
|
||||||
fun revert() {
|
fun revert() {
|
||||||
stop()
|
stop()
|
||||||
|
TrafficRecorder.update() // record stats before exiting to prevent stats losing
|
||||||
synchronized(subroutes) { subroutes.forEach { (_, subroute) -> subroute.close() } }
|
synchronized(subroutes) { subroutes.forEach { (_, subroute) -> subroute.close() } }
|
||||||
transaction.revert()
|
transaction.revert()
|
||||||
}
|
}
|
||||||
@@ -145,10 +146,13 @@ class Routing(private val owner: Context, val upstream: String?, private val dow
|
|||||||
synchronized(subroutes) {
|
synchronized(subroutes) {
|
||||||
val toRemove = HashSet(subroutes.keys)
|
val toRemove = HashSet(subroutes.keys)
|
||||||
for (client in it) if (!client.record.blocked) updateForClient(client, toRemove)
|
for (client in it) if (!client.record.blocked) updateForClient(client, toRemove)
|
||||||
|
if (toRemove.isNotEmpty()) {
|
||||||
|
TrafficRecorder.update() // record stats before removing rules to prevent stats losing
|
||||||
for (address in toRemove) subroutes.remove(address)!!.close()
|
for (address in toRemove) subroutes.remove(address)!!.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
override fun onServiceDisconnected(name: ComponentName?) {
|
override fun onServiceDisconnected(name: ComponentName?) {
|
||||||
val clients = clients ?: return
|
val clients = clients ?: return
|
||||||
clients.clientsChanged -= this
|
clients.clientsChanged -= this
|
||||||
|
|||||||
Reference in New Issue
Block a user