Skip to content

Commit

Permalink
fix(ktx): do not throw an exception when epoll does not have a valid …
Browse files Browse the repository at this point in the history
…socket.
  • Loading branch information
ThibaultBee committed Sep 2, 2024
1 parent 92fc01b commit 2070a7b
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import io.github.thibaultbee.srtdroid.core.enums.SockOpt
import io.github.thibaultbee.srtdroid.core.enums.SockStatus
import io.github.thibaultbee.srtdroid.core.interfaces.ConfigurableSrtSocket
import io.github.thibaultbee.srtdroid.core.models.Epoll
import io.github.thibaultbee.srtdroid.core.models.SrtError
import io.github.thibaultbee.srtdroid.core.models.MsgCtrl
import io.github.thibaultbee.srtdroid.core.models.SrtError
import io.github.thibaultbee.srtdroid.core.models.SrtSocket
import io.github.thibaultbee.srtdroid.core.models.SrtSocket.ServerListener
import io.github.thibaultbee.srtdroid.core.models.Stats
Expand Down Expand Up @@ -756,6 +756,7 @@ private constructor(
block: () -> T
): T {
val epoll = Epoll()
// flags = listOf(EpollFlag.ENABLE_EMPTY)
epoll.addUSock(socket, listOf(EpollOpt.ERR, epollOpt))

try {
Expand Down Expand Up @@ -803,7 +804,9 @@ private constructor(
val epollEvents = try {
epoll.uWait(POLLING_TIMEOUT_IN_MS)
} catch (e: Exception) {
continuation.resumeWithException(SocketException(SrtError.lastErrorMessage))
if (SrtError.lastError != ErrorType.EPOLLEMPTY) {
continuation.resumeWithException(SocketException(SrtError.lastErrorMessage))
}
return@suspendCancellableCoroutine
}
if (epollEvents.isEmpty()) {
Expand Down

0 comments on commit 2070a7b

Please sign in to comment.