RFR: 8370655: Check EINTR handling InetAddress implementation and NET_ThrowNew
Michael McMahon
michaelm at openjdk.org
Thu Dec 11 16:27:31 UTC 2025
On Wed, 10 Dec 2025 15:29:51 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
I’ve updated the implementation to check for EINTR from all blocking calls and all other system calls specified to be able to return EINTR, though in all cases they are used in non-blocking mode, which means the error is unlikely to occur. The new native function is removed and the test that exercised it also.
There is some reformatting of NET_Wait but no functional changes.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/28750#issuecomment-3642724298
More information about the net-dev
mailing list