mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8208715: Conversion of milliseconds to nanoseconds in UNIXProcess contains bug
Reviewed-by: martin
This commit is contained in:
parent
8cf153fbd5
commit
63b1edb7b7
4 changed files with 42 additions and 7 deletions
|
@ -497,10 +497,14 @@ final class ProcessImpl extends Process {
|
|||
if (getExitCodeProcess(handle) != STILL_ACTIVE) return true;
|
||||
if (timeout <= 0) return false;
|
||||
|
||||
long deadline = System.nanoTime() + remainingNanos ;
|
||||
long deadline = System.nanoTime() + remainingNanos;
|
||||
do {
|
||||
// Round up to next millisecond
|
||||
long msTimeout = TimeUnit.NANOSECONDS.toMillis(remainingNanos + 999_999L);
|
||||
if (msTimeout < 0) {
|
||||
// if wraps around then wait a long while
|
||||
msTimeout = Integer.MAX_VALUE;
|
||||
}
|
||||
waitForTimeoutInterruptibly(handle, msTimeout);
|
||||
if (Thread.interrupted())
|
||||
throw new InterruptedException();
|
||||
|
@ -514,7 +518,7 @@ final class ProcessImpl extends Process {
|
|||
}
|
||||
|
||||
private static native void waitForTimeoutInterruptibly(
|
||||
long handle, long timeout);
|
||||
long handle, long timeoutMillis);
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
|
|
@ -433,10 +433,10 @@ JNIEXPORT void JNICALL
|
|||
Java_java_lang_ProcessImpl_waitForTimeoutInterruptibly(JNIEnv *env,
|
||||
jclass ignored,
|
||||
jlong handle,
|
||||
jlong timeout)
|
||||
jlong timeoutMillis)
|
||||
{
|
||||
HANDLE events[2];
|
||||
DWORD dwTimeout = (DWORD)timeout;
|
||||
DWORD dwTimeout = (DWORD)timeoutMillis;
|
||||
DWORD result;
|
||||
events[0] = (HANDLE) handle;
|
||||
events[1] = JVM_GetThreadInterruptEvent();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue