Skip to content

Commit 6ceb6da

Browse files
authored
Merge pull request eclipse-openj9#20802 from theresa-m/fix_17135
Return from park immediately for non-positive time since epoch
2 parents 6b1a336 + 42ce9ec commit 6ceb6da

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

runtime/vm/threadpark.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,24 @@ threadParkImpl(J9VMThread *vmThread, BOOLEAN timeoutIsEpochRelative, I_64 timeou
4545
J9JavaVM *vm = vmThread->javaVM;
4646

4747
/* Trc_JCL_park_Entry(vmThread, timeoutIsEpochRelative, timeout); */
48-
if ((0 != timeout) || (timeoutIsEpochRelative)) {
48+
if ((0 != timeout) || timeoutIsEpochRelative) {
4949
if (timeoutIsEpochRelative) {
50-
/* Currently, the omrthread layer provides no direct support for absolute timeouts.
51-
* Simulate the timeout by calculating the delta from the current time.
52-
*/
53-
PORT_ACCESS_FROM_VMC(vmThread);
54-
I_64 timeNow = j9time_current_time_millis();
50+
if (timeout <= 0) {
51+
rc = J9THREAD_TIMED_OUT;
52+
} else {
53+
/* Currently, the omrthread layer provides no direct support for absolute timeouts.
54+
* Simulate the timeout by calculating the delta from the current time.
55+
*/
56+
PORT_ACCESS_FROM_VMC(vmThread);
57+
I_64 timeNow = j9time_current_time_millis();
5558

56-
millis = timeout - timeNow;
57-
nanos = 0;
59+
millis = timeout - timeNow;
60+
nanos = 0;
5861

59-
if (millis <= 0) {
60-
rc = J9THREAD_TIMED_OUT;
61-
/*Trc_JCL_park_timeIsInPast(vmThread, timeNow);*/
62+
if (millis <= 0) {
63+
rc = J9THREAD_TIMED_OUT;
64+
/* Trc_JCL_park_timeIsInPast(vmThread, timeNow); */
65+
}
6266
}
6367
} else {
6468
millis = timeout / oneMillion;

0 commit comments

Comments
 (0)