[jdk17u-dev] RFR: 8312065: Socket.connect does not timeout when profiling [v4]

Vyom Tewari vtewari at openjdk.org
Thu Sep 7 16:45:50 UTC 2023


On Wed, 6 Sep 2023 02:52:13 GMT, Long Yang <duke at openjdk.org> wrote:

>> Hi all,
>> 
>> This pull request contains a fix for [JDK-8312065](https://bugs.openjdk.org/browse/JDK-8312065).
>> 
>> The old SocketImpl is still present in JDK 17, can be enabled with -Djdk.net.usePlainSocketImpl.
>> 
>> I have verified that this problem exists on Linux and macOS, and I feel that it also exists on AIX, 
>> so I repaired these 3 platforms. Windows implementations are different, so don't have this problem.
>> 
>> All callers of NET_Poll() already check for EINTR, so the fix is to remove do-while loop in the implementation of NET_Poll().
>> 
>> Other methods, such as NET_Read, NET_NonBlockingRead, NET_Accept, NET_Connect, are not affected.
>> Because if Socket has timeout, it will call NET_Timeout first, and then call them. NET_Timeout has a correct timeout implementation and is not affected by profiling signals.
>> If the Socket does not have a timeout, and if the system call is interrupted by a signal, the [Linux Kernel will automatically retry](https://man7.org/linux/man-pages/man7/signal.7.html), and the application code will not be aware of it.
>> 
>> Thanks!
>
> Long Yang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   push to trigger github workflows

src/java.base/aix/native/libnet/aix_close.c line 502:

> 500:     ret = poll(ufds, nfds, timeout);
> 501:     endOp(fdEntry, &self);
> 502:     return ret;

with this approach we have lot of duplicate code what if we reuse most of the duplicate code as follows ?

#define BLOCKING_IO_RETURN_INT(FD, FUNC) {      \
    int ret;                                    \
    do {                                        \
        ret = NONBLOCKING_IO_RETURN_INT(FD, FUNC); \
    } while (ret == -1 && errno == EINTR);      \
    return ret;                                 \
}

#define NONBLOCKING_IO_RETURN_INT(FD, FUNC) {   \
    int ret;                                    \
    threadEntry_t self;                         \
    fdEntry_t *fdEntry = getFdEntry(FD);        \
    if (fdEntry == NULL) {                      \
        errno = EBADF;                          \
        return -1;                              \
    }                                           \
    startOp(fdEntry, &self);                    \
    ret = FUNC;                                 \
    endOp(fdEntry, &self);                      \
    return ret;                                 \
}

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

PR Review Comment: https://git.openjdk.org/jdk17u-dev/pull/1639#discussion_r1318875930


More information about the jdk-updates-dev mailing list