Merge pull request #1408 from drewhk/wip-selector-wakeup-miss-drewhk

Fixed race causing missed wakeups
This commit is contained in:
drewhk 2013-05-07 11:43:32 -07:00
commit 088f1019d7

View file

@ -164,7 +164,6 @@ private[io] class SelectionHandler(settings: SelectionHandlerSettings) extends A
val select = new Task {
def tryRun(): Unit = {
wakeUp.set(false) // Reset early, worst-case we do a double-wakeup, but it's supposed to be idempotent so it's just an extra syscall
if (selector.select() > 0) { // This assumes select return value == selectedKeys.size
val keys = selector.selectedKeys
val iterator = keys.iterator()
@ -194,6 +193,7 @@ private[io] class SelectionHandler(settings: SelectionHandlerSettings) extends A
keys.clear() // we need to remove the selected keys from the set, otherwise they remain selected
}
wakeUp.set(false)
// FIXME what is the appropriate error-handling here, shouldn't this task be resubmitted in case of exception?
selectorManagementEC.execute(this) // re-schedules select behind all currently queued tasks
}