8203369: Check for both EAGAIN and EWOULDBLOCK error codes
Reviewed-by: alanb
This commit is contained in:
parent
a9d29cf43a
commit
33b7f68964
src
java.base
linux/classes/sun/nio/fs
unix
classes/sun/nio/fs
native
jdk.sctp/unix/native/libsctp
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -319,7 +319,7 @@ class LinuxWatchService
|
||||
try {
|
||||
bytesRead = read(ifd, address, BUFFER_SIZE);
|
||||
} catch (UnixException x) {
|
||||
if (x.errno() != EAGAIN)
|
||||
if (x.errno() != EAGAIN && x.errno() != EWOULDBLOCK)
|
||||
throw x;
|
||||
bytesRead = 0;
|
||||
}
|
||||
@ -367,7 +367,7 @@ class LinuxWatchService
|
||||
if (shutdown)
|
||||
break;
|
||||
} catch (UnixException x) {
|
||||
if (x.errno() != UnixConstants.EAGAIN)
|
||||
if (x.errno() != EAGAIN && x.errno() != EWOULDBLOCK)
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -22,7 +21,6 @@
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
@@END_COPYRIGHT@@
|
||||
@ -111,6 +109,7 @@ class UnixConstants {
|
||||
static final int PREFIX_ENOTEMPTY = ENOTEMPTY;
|
||||
static final int PREFIX_ENOSPC = ENOSPC;
|
||||
static final int PREFIX_EAGAIN = EAGAIN;
|
||||
static final int PREFIX_EWOULDBLOCK = EWOULDBLOCK;
|
||||
static final int PREFIX_ENOSYS = ENOSYS;
|
||||
static final int PREFIX_ELOOP = ELOOP;
|
||||
static final int PREFIX_EROFS = EROFS;
|
||||
|
@ -630,8 +630,8 @@ Java_java_net_PlainSocketImpl_socketAccept(JNIEnv *env, jobject this,
|
||||
* before accept() was called.
|
||||
*
|
||||
* If accept timeout in place and timeout is adjusted with
|
||||
* each ECONNABORTED or EWOULDBLOCK to ensure that semantics
|
||||
* of timeout are preserved.
|
||||
* each ECONNABORTED or EWOULDBLOCK or EAGAIN to ensure that
|
||||
* semantics of timeout are preserved.
|
||||
*/
|
||||
for (;;) {
|
||||
int ret;
|
||||
@ -673,12 +673,12 @@ Java_java_net_PlainSocketImpl_socketAccept(JNIEnv *env, jobject this,
|
||||
break;
|
||||
}
|
||||
|
||||
/* non (ECONNABORTED or EWOULDBLOCK) error */
|
||||
if (!(errno == ECONNABORTED || errno == EWOULDBLOCK)) {
|
||||
/* non (ECONNABORTED or EWOULDBLOCK or EAGAIN) error */
|
||||
if (!(errno == ECONNABORTED || errno == EWOULDBLOCK || errno == EAGAIN)) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* ECONNABORTED or EWOULDBLOCK error so adjust timeout if there is one. */
|
||||
/* ECONNABORTED or EWOULDBLOCK or EAGAIN error so adjust timeout if there is one. */
|
||||
if (nanoTimeout >= NET_NSEC_PER_MSEC) {
|
||||
currNanoTime = JVM_NanoTime(env, 0);
|
||||
nanoTimeout -= (currNanoTime - prevNanoTime);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -142,7 +142,7 @@ Java_sun_nio_ch_DatagramChannelImpl_receive0(JNIEnv *env, jobject this,
|
||||
retry = JNI_FALSE;
|
||||
n = recvfrom(fd, buf, len, 0, &sa.sa, &sa_len);
|
||||
if (n < 0) {
|
||||
if (errno == EWOULDBLOCK) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
return IOS_UNAVAILABLE;
|
||||
}
|
||||
if (errno == EINTR) {
|
||||
@ -217,7 +217,7 @@ Java_sun_nio_ch_DatagramChannelImpl_send0(JNIEnv *env, jobject this,
|
||||
|
||||
n = sendto(fd, buf, len, 0, &sa.sa, sa_len);
|
||||
if (n < 0) {
|
||||
if (errno == EAGAIN) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
return IOS_UNAVAILABLE;
|
||||
}
|
||||
if (errno == EINTR) {
|
||||
|
@ -120,7 +120,7 @@ Java_sun_nio_ch_IOUtil_drain(JNIEnv *env, jclass cl, jint fd)
|
||||
for (;;) {
|
||||
int n = read(fd, buf, sizeof(buf));
|
||||
tn += n;
|
||||
if ((n < 0) && (errno != EAGAIN))
|
||||
if ((n < 0) && (errno != EAGAIN && errno != EWOULDBLOCK))
|
||||
JNU_ThrowIOExceptionWithLastError(env, "Drain");
|
||||
if (n == (int)sizeof(buf))
|
||||
continue;
|
||||
@ -136,7 +136,7 @@ Java_sun_nio_ch_IOUtil_drain1(JNIEnv *env, jclass cl, jint fd)
|
||||
|
||||
res = read(fd, buf, 1);
|
||||
if (res < 0) {
|
||||
if (errno == EAGAIN) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
res = 0;
|
||||
} else if (errno == EINTR) {
|
||||
return IOS_INTERRUPTED;
|
||||
@ -187,7 +187,7 @@ convertReturnVal(JNIEnv *env, jint n, jboolean reading)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (errno == EAGAIN)
|
||||
else if (errno == EAGAIN || errno == EWOULDBLOCK)
|
||||
return IOS_UNAVAILABLE;
|
||||
else if (errno == EINTR)
|
||||
return IOS_INTERRUPTED;
|
||||
@ -212,7 +212,7 @@ convertLongReturnVal(JNIEnv *env, jlong n, jboolean reading)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (errno == EAGAIN)
|
||||
else if (errno == EAGAIN || errno == EWOULDBLOCK)
|
||||
return IOS_UNAVAILABLE;
|
||||
else if (errno == EINTR)
|
||||
return IOS_INTERRUPTED;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -103,7 +103,7 @@ Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv *env, jobject this,
|
||||
}
|
||||
|
||||
if (newfd < 0) {
|
||||
if (errno == EAGAIN)
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK)
|
||||
return IOS_UNAVAILABLE;
|
||||
if (errno == EINTR)
|
||||
return IOS_INTERRUPTED;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -439,7 +439,7 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_receive0
|
||||
|
||||
do {
|
||||
if ((rv = recvmsg(fd, msg, flags)) < 0) {
|
||||
if (errno == EWOULDBLOCK) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
return IOS_UNAVAILABLE;
|
||||
} else if (errno == EINTR) {
|
||||
return IOS_INTERRUPTED;
|
||||
@ -582,7 +582,7 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_send0
|
||||
setControlData(msg, cdata);
|
||||
|
||||
if ((rv = sendmsg(fd, msg, 0)) < 0) {
|
||||
if (errno == EWOULDBLOCK) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
return IOS_UNAVAILABLE;
|
||||
} else if (errno == EINTR) {
|
||||
return IOS_INTERRUPTED;
|
||||
|
Loading…
x
Reference in New Issue
Block a user