RFR [11] 8200304: TwoStacksPlainDatagramSocketImpl and socket cleaner
Roger Riggs
Roger.Riggs at Oracle.com
Wed Mar 28 18:47:00 UTC 2018
Hi Chris,
TwoStacksPlainDatagramSocketImpl.java:136 could be explicit about the
native bind0
changing the state.
And I agree with Alan that the calls to updateCleaner (:144) should
occur whether or not
the native bind0 throws an exception.
Thanks, Roger
On 3/28/2018 1:22 PM, Alan Bateman wrote:
> On 28/03/2018 10:08, Chris Hegarty wrote:
>> 8195059 [1] updated the socket implementation to use a cleaner,
>> rather than the previous finalizer implementation. Unfortunately the
>> TwoStacksPlainDatagramSocketImpl on Windows, that uses two
>> native file descriptors, may close one or other when binding, or it
>> may in fact close both sockets and create two completely new
>> ones. This is problematic since the cleaner has been registered
>> with the native file descriptors of the original `fd` and `fd1` when
>> the impl was created. As such, the cleaner may interfere with
>> other resources that happen to re-use the native file descriptor.
>>
>> This area of code is ultimately destined for replacement with the
>> dual stack implementation, but unfortunately we’re not quite at
>> that point yet, so I would like to resolve this issue with a small
>> localised fix that checks the file descriptors before and after the
>> actual bind call, unregistering and re-registering the cleaner as
>> necessary.
>>
>> http://cr.openjdk.java.net/~chegar/8200304/00/
>>
> It's great that this issue has been tracked down.
>
> bind0 can try an exception so shouldn't there be a try-finally around
> this? Also would it be saner to unregister before bind0 and register
> afresh after it is called so that there is no point where a closed
> socket is registered with the cleaner?
>
> -Alan
More information about the net-dev
mailing list