Commit 244f9978 authored by Mygod's avatar Mygod

Fix race condition in cancelling keys in ChannelMonitor

parent f10f11d4
......@@ -81,7 +81,9 @@ class ChannelMonitor : Thread("ChannelMonitor") {
suspend fun wait(channel: SelectableChannel, ops: Int) = CompletableDeferred<SelectionKey>().run {
register(channel, ops) {
if (it.isValid) it.interestOps(0) // stop listening
if (it.isValid) try {
it.interestOps(0) // stop listening
} catch (_: CancelledKeyException) { }
complete(it)
}
await()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment