Prevent crash while releasing RootManager

This commit is contained in:
Mygod
2020-08-07 07:02:40 +08:00
parent e7cf432348
commit b6793ff59c

View File

@@ -140,7 +140,13 @@ abstract class IpMonitor {
/** /**
* Possibly blocking. Should run in IO dispatcher or use [flushAsync]. * Possibly blocking. Should run in IO dispatcher or use [flushAsync].
*/ */
suspend fun flush() = work(null)?.let { RootManager.release(it) } suspend fun flush() = work(null)?.let {
try {
RootManager.release(it)
} catch (e: Exception) {
Timber.w(e)
}
}
fun flushAsync() = GlobalScope.launch(Dispatchers.IO) { flush() } fun flushAsync() = GlobalScope.launch(Dispatchers.IO) { flush() }
private suspend fun work(server: RootServer?): RootServer? { private suspend fun work(server: RootServer?): RootServer? {