Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
IO.select raises CancelledKeyException on shutdown #1580
If I have a thread blocking on
I haven't been able to force this to happen when pressing ctrl-C on a running process, and it doesn't happen every time, but often.
I've observed it in JRuby 1.7.10 and 1.7.11.
From looking at the code (https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/util/io/SelectBlob.java#L340) it seems like there are two possibilities on how to end up on line 340, either
There's another odd thing in the
Here's a test case, of sorts, that stresses
queue = java.util.concurrent.ConcurrentLinkedQueue.new t = Thread.start do begin while true begin r, w = IO.pipe queue.add([r, w]) IO.select([r], nil, [r], 0.1) rescue Errno::EBADF end end rescue java.nio.channels.CancelledKeyException puts "THIS SHOULD NOT HAPPEN" end end while t.alive? pair = queue.poll if pair r, w = pair w.syswrite('x') r.to_java.channel.close end end puts 'FAIL!'
I'm looking at the code and am trying to figure out what it is supposed to do when a CKE is thrown, I'm not sure if there's any cleanup that absolutely must be done. The easiest thing would be to raise a