mirror of
https://github.com/MatsuriDayo/NekoBoxForAndroid.git
synced 2025-12-20 07:00: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(
|
SystemClock.elapsedRealtime() - startTime < 1000 -> throw IOException(
|
||||||
"$cmdName exits too fast (exit code: $exitCode)"
|
"$cmdName exits too fast (exit code: $exitCode)"
|
||||||
)
|
)
|
||||||
|
|
||||||
exitCode == 128 + OsConstants.SIGKILL -> Logs.w("$cmdName was killed")
|
exitCode == 128 + OsConstants.SIGKILL -> Logs.w("$cmdName was killed")
|
||||||
else -> Logs.w(IOException("$cmdName unexpectedly exits with code $exitCode"))
|
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()
|
override val coroutineContext = Dispatchers.Main.immediate + Job()
|
||||||
|
var processCount = 0
|
||||||
|
|
||||||
@MainThread
|
@MainThread
|
||||||
fun start(
|
fun start(
|
||||||
@ -111,6 +113,7 @@ class GuardedProcessPool(private val onFatal: suspend (IOException) -> Unit) : C
|
|||||||
start() // if start fails, IOException will be thrown directly
|
start() // if start fails, IOException will be thrown directly
|
||||||
launch { looper(onRestartCallback) }
|
launch { looper(onRestartCallback) }
|
||||||
}
|
}
|
||||||
|
processCount += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainThread
|
@MainThread
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import io.nekohasekai.sagernet.ktx.Logs
|
|||||||
import io.nekohasekai.sagernet.ktx.runOnDefaultDispatcher
|
import io.nekohasekai.sagernet.ktx.runOnDefaultDispatcher
|
||||||
import io.nekohasekai.sagernet.ktx.tryResume
|
import io.nekohasekai.sagernet.ktx.tryResume
|
||||||
import io.nekohasekai.sagernet.ktx.tryResumeWithException
|
import io.nekohasekai.sagernet.ktx.tryResumeWithException
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import libcore.Libcore
|
import libcore.Libcore
|
||||||
import kotlin.coroutines.suspendCoroutine
|
import kotlin.coroutines.suspendCoroutine
|
||||||
|
|
||||||
@ -25,6 +26,10 @@ class TestInstance(profile: ProxyEntity, val link: String, val timeout: Int) :
|
|||||||
try {
|
try {
|
||||||
init()
|
init()
|
||||||
launch()
|
launch()
|
||||||
|
if (processes.processCount > 0) {
|
||||||
|
// wait for plugin start
|
||||||
|
delay(500)
|
||||||
|
}
|
||||||
c.tryResume(Libcore.urlTest(box, link, timeout))
|
c.tryResume(Libcore.urlTest(box, link, timeout))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
c.tryResumeWithException(e)
|
c.tryResumeWithException(e)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user