Prevent RootServer.create cancelling the entire scope

This commit is contained in:
Mygod
2020-11-08 01:48:43 -05:00
parent fe07e2678a
commit 795caee54d
2 changed files with 2 additions and 3 deletions

View File

@@ -270,7 +270,7 @@ class RootServer {
@Throws(RemoteException::class) @Throws(RemoteException::class)
fun <T : Parcelable?> create(command: RootCommandChannel<T>, scope: CoroutineScope, fun <T : Parcelable?> create(command: RootCommandChannel<T>, scope: CoroutineScope,
classLoader: ClassLoader?) = scope.produce<T>( classLoader: ClassLoader?) = scope.produce<T>(
capacity = command.capacity.also { SupervisorJob(), command.capacity.also {
when (it) { when (it) {
Channel.UNLIMITED, Channel.CONFLATED -> { } Channel.UNLIMITED, Channel.CONFLATED -> { }
else -> throw IllegalArgumentException("Unsupported channel capacity $it") else -> throw IllegalArgumentException("Unsupported channel capacity $it")

View File

@@ -21,7 +21,6 @@ import timber.log.Timber
import java.io.IOException import java.io.IOException
import java.io.InterruptedIOException import java.io.InterruptedIOException
import kotlin.concurrent.thread import kotlin.concurrent.thread
import kotlin.coroutines.EmptyCoroutineContext
abstract class IpMonitor { abstract class IpMonitor {
companion object { companion object {
@@ -109,7 +108,7 @@ abstract class IpMonitor {
if (destroyed) return@thread if (destroyed) return@thread
} }
try { try {
runBlocking(EmptyCoroutineContext + worker) { runBlocking(worker) {
RootManager.use { server -> RootManager.use { server ->
// while we only need to use this server once, we need to also keep the server alive // while we only need to use this server once, we need to also keep the server alive
handleChannel(server.create(ProcessListener(errorMatcher, Routing.IP, "monitor", monitoredObject), handleChannel(server.create(ProcessListener(errorMatcher, Routing.IP, "monitor", monitoredObject),