RFR[11] of JDK-8208280,java/nio/channels/Selector/RegisterDuringSelect.java fails with "key not removed from key set"

Hamlin Li huaming.li at oracle.com
Fri Jul 27 06:58:19 UTC 2018

Would you please review the following patch?

bug: https://bugs.openjdk.java.net/browse/JDK-8208280

webrev: http://cr.openjdk.java.net/~mli/8208280/webrev.00/

The issue may occur intermittently, the main reason is that on windows 
Pipe is implemented as a pair of socket, so sinked byte might not be 
immediately available at source side. Steps for the issue to occur:
1. 2nd sel.wakeup() is invoked before 2nd select() and the sinked 1 byte 
is not read out by resetWakeupSocket0 because it might not be 
immediately available at source side and ioctlsocket may report 0 byte, 
so select() return quickly before invocation of native select() method;
2. the previously sinked 1 byte arrives at source side;
3. 3rd select() is invoked and finishes quickly before 
key.cancel()/sel.wakeup() is invoked because previously sinked 1 byte is 
still in source side;
4. after 3rd select() returns, key.cancel() is invoked but it has no 
effect on sel.keys(), so sel.keys() still contains the just canceled key.

Thank you


More information about the nio-dev mailing list