Skip to content

Commit bb5bc85

Browse files
committed
Merge openj9 into openj9-staging
Signed-off-by: Peter Shipton <Peter_Shipton@ca.ibm.com>
2 parents b06cc96 + 8a19fb2 commit bb5bc85

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

make/autoconf/util.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ AC_DEFUN([UTIL_ADD_JVM_ARG_IF_OK],
335335
$ECHO "Check if jvm arg is ok: $1" >&AS_MESSAGE_LOG_FD
336336
$ECHO "Command: $3 $1 -version" >&AS_MESSAGE_LOG_FD
337337
OUTPUT=`$3 $1 $USER_BOOT_JDK_OPTIONS -version 2>&1`
338-
FOUND_WARN=`$ECHO "$OUTPUT" | $GREP -i "warn\|unrecognised"`
338+
FOUND_WARN=`$ECHO "$OUTPUT" | $GREP -E -i "warn|unrecognised"`
339339
FOUND_VERSION=`$ECHO $OUTPUT | $GREP " version \""`
340340
if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
341341
$2="[$]$2 $1"

src/java.base/linux/native/libnio/ch/EPoll.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,17 @@
2323
* questions.
2424
*/
2525

26+
/*
27+
* ===========================================================================
28+
* (c) Copyright IBM Corp. 2026, 2026 All Rights Reserved
29+
* ===========================================================================
30+
*/
31+
2632
#include <dlfcn.h>
2733
#include <unistd.h>
2834
#include <sys/types.h>
2935
#include <sys/epoll.h>
36+
#include <time.h>
3037

3138
#include "jni.h"
3239
#include "jni_util.h"
@@ -83,11 +90,41 @@ Java_sun_nio_ch_EPoll_wait(JNIEnv *env, jclass clazz, jint epfd,
8390
jlong address, jint numfds, jint timeout)
8491
{
8592
struct epoll_event *events = jlong_to_ptr(address);
93+
struct timespec starttime;
94+
if (-1 != timeout) {
95+
clock_gettime(CLOCK_MONOTONIC, &starttime);
96+
}
8697
int res = epoll_wait(epfd, events, numfds, timeout);
8798
if (res < 0) {
8899
if (errno == EINTR) {
89100
return IOS_INTERRUPTED;
90101
} else {
102+
if (EINVAL == errno) {
103+
jint newtimeout = -1;
104+
if (-1 != timeout) {
105+
time_t elapsedsec = 0;
106+
long elapsedmillis = 0;
107+
struct timespec endtime;
108+
clock_gettime(CLOCK_MONOTONIC, &endtime);
109+
elapsedsec = endtime.tv_sec - starttime.tv_sec - 1;
110+
elapsedmillis = (endtime.tv_nsec + 1000000000 - starttime.tv_nsec) / 1000000;
111+
newtimeout = timeout - (elapsedsec * 1000) - elapsedmillis;
112+
if (newtimeout < 0) {
113+
newtimeout = 0;
114+
}
115+
}
116+
res = epoll_wait(epfd, events, numfds, newtimeout);
117+
if (res < 0) {
118+
if (errno == EINTR) {
119+
return IOS_INTERRUPTED;
120+
} else {
121+
JNU_ThrowIOExceptionWithLastError(env, "epoll_wait failed");
122+
return IOS_THROWN;
123+
}
124+
} else {
125+
return res;
126+
}
127+
}
91128
JNU_ThrowIOExceptionWithLastError(env, "epoll_wait failed");
92129
return IOS_THROWN;
93130
}

0 commit comments

Comments
 (0)