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

Long Yang duke at openjdk.org
Fri Sep 8 11:40:52 UTC 2023


On Thu, 7 Sep 2023 18:35:02 GMT, Paul Hohensee <phh at openjdk.org> wrote:

> Code duplication is the source of many bugs, so instead of duplicating the macro code inline, add a RETRY macro argument, vis,
> 
> ```
> #define false 0
> #define true 1
> 
> #define BLOCKING_IO_RETURN_INT(FD, FUNC, RETRY) {     \
>     int ret;                                          \
>     threadEntry_t self;                               \
>     fdEntry_t *fdEntry = getFdEntry(FD);              \
>     if (fdEntry == NULL) {                            \
>         errno = EBADF;                                \
>         return -1;                                    \
>     }                                                 \
>     do {                                              \
>         startOp(fdEntry, &self);                      \
>         ret = FUNC;                                   \
>         endOp(fdEntry, &self);                        \
>     } while ((RETRY) && ret == -1 && errno == EINTR); \
>     return ret;                                       \
> }
> ```
> 
> Then, add "true" as the last argument to all invocations of the macro, except the one in NET_Poll, which becomes
> 
> ```
> int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
>     BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout), false );
> }
> ```

Paul, Thank you very much for your detailed advice.

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

PR Comment: https://git.openjdk.org/jdk17u-dev/pull/1639#issuecomment-1711529060


More information about the jdk-updates-dev mailing list