RFR : 8205959 : Do not restart close if errno is EINTR

Ivan Gerasimov ivan.gerasimov at oracle.com
Wed Jun 27 23:52:03 UTC 2018


Thanks David!


On 6/27/18 4:23 PM, David Lloyd wrote:
> According to http://man7.org/linux/man-pages/man2/close.2.html it is 
> currently platform-dependent whether close() must or must not (seems 
> to be no middle ground) be retried.  Might have to do some #ifdef 
> guarding?
>
Right.

Here I'm patching only the Linux-specific file 
src/java.base/linux/native/libnet/linux_close.c
So no #ifdefs seem necessary.

MacOS variant also uses the same pattern, but I'm not touching it 
exactly because the behavior not quite clear on that platform.

On Solaris we already call close(fd) with no retrying.

With kind regards,
Ivan

> -- 
> - DML
>
>
> On Jun 27, 2018, at 6:15 PM, Ivan Gerasimov <ivan.gerasimov at oracle.com 
> <mailto:ivan.gerasimov at oracle.com>> wrote:
>
>> Hello!
>>
>> When closing a socket via NET_SocketClose(int fd), a close(fd) is called.
>> The later is wrapped in a retry-loop, which is wrong because close() 
>> is not restartable.
>>
>> The `man 2 close` states:
>> """
>> ... close() should not be retried after an EINTR since this may cause 
>> a reused descriptor from another thread to be closed.
>> """
>>
>> Would you please help review a trivial fix?
>>
>> BUGURL: https://bugs.openjdk.java.net/browse/JDK-8205959
>> WEBREV: http://cr.openjdk.java.net/~igerasim/8205959/00/webrev/ 
>> <http://cr.openjdk.java.net/%7Eigerasim/8205959/00/webrev/>
>>
>> Thanks in advance!
>>
>> -- 
>> With kind regards,
>> Ivan Gerasimov
>>

-- 
With kind regards,
Ivan Gerasimov

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/net-dev/attachments/20180627/94eb7c46/attachment.html>


More information about the net-dev mailing list