diff --git a/library/runtime-core/src/jsMain/kotlin/io/matthewnelson/kmp/tor/runtime/core/util/PortUtil.kt b/library/runtime-core/src/jsMain/kotlin/io/matthewnelson/kmp/tor/runtime/core/util/PortUtil.kt index f90b07781..16641b632 100644 --- a/library/runtime-core/src/jsMain/kotlin/io/matthewnelson/kmp/tor/runtime/core/util/PortUtil.kt +++ b/library/runtime-core/src/jsMain/kotlin/io/matthewnelson/kmp/tor/runtime/core/util/PortUtil.kt @@ -106,6 +106,8 @@ private suspend fun IPAddress.isPortAvailable(port: Int): Boolean { latch.cancel() } + val waitTime = (if (IsUnixLikeHost) 42 else 84).milliseconds + while ( ctx.isActive && latch.isActive @@ -113,7 +115,7 @@ private suspend fun IPAddress.isPortAvailable(port: Int): Boolean { && error == null ) { delay(1.milliseconds) - if (timeMark.elapsedNow() > 42.milliseconds) break + if (timeMark.elapsedNow() > waitTime) break } } finally { latch.cancel() diff --git a/library/runtime-ctrl/src/jsMain/kotlin/io/matthewnelson/kmp/tor/runtime/ctrl/TorCtrl.kt b/library/runtime-ctrl/src/jsMain/kotlin/io/matthewnelson/kmp/tor/runtime/ctrl/TorCtrl.kt index a87d7433c..6aa5bd832 100644 --- a/library/runtime-ctrl/src/jsMain/kotlin/io/matthewnelson/kmp/tor/runtime/ctrl/TorCtrl.kt +++ b/library/runtime-ctrl/src/jsMain/kotlin/io/matthewnelson/kmp/tor/runtime/ctrl/TorCtrl.kt @@ -166,7 +166,6 @@ public actual interface TorCtrl : Destroyable, TorEvent.Processor, TorCmd.Privil fun callback(nread: Int, buf: dynamic) { val jsBuf = Buffer.wrap(buf) val readBuf = ReadBuffer.of(jsBuf) - // TODO: try/catch IllegalState? feed.onData(readBuf, nread) } @@ -282,7 +281,7 @@ public actual interface TorCtrl : Destroyable, TorEvent.Processor, TorCmd.Privil // A slight delay is needed before returning in order // to ensure that the coroutine starts before able // to call destroy on it. - delay(25.milliseconds) + delay(42.milliseconds) } catch (t: Throwable) { ctrl.destroy() throw t