RFR: 8370655: Check EINTR handling InetAddress implementation and NET_ThrowNew [v2]

Alan Bateman alanb at openjdk.org
Thu Dec 11 17:11:09 UTC 2025


On Thu, 11 Dec 2025 16:27:29 GMT, Michael McMahon <michaelm at openjdk.org> wrote:

>> Hi,
>> 
>> This change updates the use of NET_ThrowNew in Inet4AddressImpl.c + Inet6AddressImpl.c (unix).
>> Currently EINTR is incorrectly handled in NET_ThrowNew to throw InterruptedIOException.
>> 
>> The only possible places in these files where EINTR can be returned is in the sendto() calls
>> for ping4() and ping6() used by the InetAddress.isReachable() API.
>> 
>> The change checks for EINTR returned from those calls and restarts the sendto()
>> if the timeout allows it. If EINTR is detected by NET_ThrowNew it is thrown as an ordinary
>> SocketException, but this should not happen.
>> 
>> The fix is only partially tested as it is difficult to make sendto() return EINTR in practice, but
>> I added a unit test for the new native function that checks if the timeout has expired.
>> 
>> Thanks,
>> Michael
>
> Michael McMahon has updated the pull request incrementally with five additional commits since the last revision:
> 
>  - impl update
>  - update
>  - header file update
>  - impl update
>  - removed test updated impl

src/java.base/unix/native/libnet/Inet4AddressImpl.c line 112:

> 110: 
> 111:     NET_RESTARTABLE(error, getaddrinfo(hostname, NULL, &hints, &res),
> 112:                     error != EAI_SYSTEM)

Have you verified that a pthread_kill of a thread blocked in getaddrinfo returns EAI_SYSTEM with errno=EINTR?  I can't be sure from the man page.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28750#discussion_r2611389658


More information about the net-dev mailing list