Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-check thread events immediately before blocking call.
This is the likely cause of unreliable cross-thread events in Queue and Fiber (which uses SizedQueue). The queue.pop logic uses RubyThread.executeTask, which receives a function object for unblocking and an argument to pass to that function. An interrupt of the thread during this operation will call the function and presumably wake the thread in some safe way. However, if the interrupt triggered between the last event poll and the assignment of the unblocker, it could be lost and the blocking call never interrupted. This resulted in several thread/fiber tests having unpredictable behavior. This also could trigger an improper InterruptedException or ThreadError during a Fiber resume or yield. The fix here does an extra poll *after* assigning the unblocker, so that any interrupts fired are executed before proceeding into the blocking section.