diff --git a/app/src/main/java/io/nekohasekai/sagernet/bg/GuardedProcessPool.kt b/app/src/main/java/io/nekohasekai/sagernet/bg/GuardedProcessPool.kt index db70000..cded1ca 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/bg/GuardedProcessPool.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/bg/GuardedProcessPool.kt @@ -64,6 +64,7 @@ class GuardedProcessPool(private val onFatal: suspend (IOException) -> Unit) : C SystemClock.elapsedRealtime() - startTime < 1000 -> throw IOException( "$cmdName exits too fast (exit code: $exitCode)" ) + exitCode == 128 + OsConstants.SIGKILL -> Logs.w("$cmdName was killed") else -> Logs.w(IOException("$cmdName unexpectedly exits with code $exitCode")) } @@ -99,6 +100,7 @@ class GuardedProcessPool(private val onFatal: suspend (IOException) -> Unit) : C } override val coroutineContext = Dispatchers.Main.immediate + Job() + var processCount = 0 @MainThread fun start( @@ -111,6 +113,7 @@ class GuardedProcessPool(private val onFatal: suspend (IOException) -> Unit) : C start() // if start fails, IOException will be thrown directly launch { looper(onRestartCallback) } } + processCount += 1 } @MainThread diff --git a/app/src/main/java/io/nekohasekai/sagernet/bg/proto/TestInstance.kt b/app/src/main/java/io/nekohasekai/sagernet/bg/proto/TestInstance.kt index e4b85df..73166bb 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/bg/proto/TestInstance.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/bg/proto/TestInstance.kt @@ -8,6 +8,7 @@ import io.nekohasekai.sagernet.ktx.Logs import io.nekohasekai.sagernet.ktx.runOnDefaultDispatcher import io.nekohasekai.sagernet.ktx.tryResume import io.nekohasekai.sagernet.ktx.tryResumeWithException +import kotlinx.coroutines.delay import libcore.Libcore import kotlin.coroutines.suspendCoroutine @@ -25,6 +26,10 @@ class TestInstance(profile: ProxyEntity, val link: String, val timeout: Int) : try { init() launch() + if (processes.processCount > 0) { + // wait for plugin start + delay(500) + } c.tryResume(Libcore.urlTest(box, link, timeout)) } catch (e: Exception) { c.tryResumeWithException(e)