Skip to content

Commit b0d48b7

Browse files
committed
fixup! fixup! KTOR-1159 Add support for UDP sockets on native
Workaround for Kotlin/kotlinx.coroutines#2263
1 parent a09e961 commit b0d48b7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ktor-network/posix/src/io/ktor/network/sockets/DatagramSendChannel.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ internal class DatagramSendChannel(
2525

2626
@ExperimentalCoroutinesApi
2727
override val isFull: Boolean
28-
get() = if (isClosedForSend) false else lock.isLocked
28+
get() = if (isClosedForSend) false else lock.availablePermits == 0
2929

30-
private val lock = Mutex()
30+
private val lock = Semaphore(1)
3131

3232
override fun close(cause: Throwable?): Boolean {
3333
// if (socket.isClosed) {
@@ -44,7 +44,7 @@ internal class DatagramSendChannel(
4444
}
4545

4646
override suspend fun send(element: Datagram) {
47-
lock.withLock {
47+
lock.withPermit {
4848
sendImpl(element)
4949
}
5050
}

0 commit comments

Comments
 (0)