Allow unregister to fail

Race condition might occur when cleaning.
This commit is contained in:
Mygod
2018-10-04 19:45:54 +08:00
parent 722855caf7
commit c7e79dfb6a

View File

@@ -37,7 +37,8 @@ object TrafficRecorder {
}
fun unregister(ip: InetAddress, upstream: String?, downstream: String) = synchronized(this) {
update() // flush stats before removing
check(records.remove(Triple(ip, upstream, downstream)) != null)
if (records.remove(Triple(ip, upstream, downstream)) == null) Timber.w(
"Failed to find traffic record for ($ip, $downstream, $upstream).")
}
private fun unscheduleUpdateLocked() {