mirror of
https://github.com/MatsuriDayo/NekoBoxForAndroid.git
synced 2025-12-19 22:50:05 +08:00
chore: Waiting for the plugin when url test
This commit is contained in:
parent
a1ae327234
commit
b525b3a964
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user