On Wed, 10 Dec 2025 15:29:51 GMT, Michael McMahon <[email protected]> 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

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

> 399:         icmp->icmp_cksum = in_cksum((u_short *)icmp, plen);
> 400:         // send it
> 401:         while (1) {

Are you sure it is possible for sendto to block indefinitely here? Maybe EINTR 
is possible but I think it would be okay to retry unconditionally, meaning I 
don't think timerMillisExpired is needed here.

Are you sure that we restart for the other blocking syscalls (poll, recvfrom, 
...) in these methods?

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

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

Reply via email to