Review Request : JDK-8002306, (se) Selector.open fails if invoked with thread interrupt status set [win]
Dan Xu
dan.xu at oracle.com
Mon Dec 10 16:24:25 PST 2012
On 12/10/2012 02:51 PM, David M. Lloyd wrote:
> On 12/10/2012 04:28 PM, Dan Xu wrote:
>> Hi folks,
>>
>> Please help review the fix for JDK-8002306, Selector.open fails if
>> invoked with thread interrupt status set [win], at
>> http://cr.openjdk.java.net/~dxu/8002306/webrev/
>> <http://cr.openjdk.java.net/%7Edxu/8002306/webrev/>
>>
>> On windows, we establish loopback socket connections every time a
>> selector is opened. But the connect operation will fail and throw out
>> ClosedByInterruptException if its current thread is interrupted. In
>> order to open a selector on an interrupted thread successfully, the fix
>> clears the interrupt status, establish socket connections, and reset the
>> status to interrupt afterwards to work around the restrictions. Thanks!
>
> There will still be a race where the thread interrupt status could be
> set after it was cleared but before the selector is created.
>
> I think there are probably only two viable options here:
>
> 1. Treat the current behavior as "correct": you cannot open a selector
> when the current thread is interrupted.
> 2. Rewrite the selector open operation such that it creates the socket
> without respecting the state of the interrupted flag.
>
The issue of this bug is not only the exception, but also the same code
has different behaviour on Windows in comparison with other platforms.
In my understanding, it should deliver the same result on all supported
platforms.
I briefed the race issue to Alan in the weekend. And in order to fix it,
I need more support from the lower layer, which needs to extend the
scope of the fix.
-Dan
More information about the nio-dev
mailing list