# HG changeset patch # User igerasim # Date 1527277474 25200 # Node ID 69204b98dc3da9f7c72c4596d9aed26364fdd8ff # Parent 33a890c972c3731848322ba1ec5e8d5e77b87e1d 8203369: Check for both EAGAIN and EWOULDBLOCK error codes Reviewed-by: alanb diff -r 33a890c972c3 -r 69204b98dc3d src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java --- a/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java Fri May 25 11:59:01 2018 -0700 +++ b/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java Fri May 25 12:44:34 2018 -0700 @@ -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 @@ 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 @@ if (shutdown) break; } catch (UnixException x) { - if (x.errno() != UnixConstants.EAGAIN) + if (x.errno() != EAGAIN && x.errno() != EWOULDBLOCK) throw x; } } diff -r 33a890c972c3 -r 69204b98dc3d src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template --- a/src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template Fri May 25 11:59:01 2018 -0700 +++ b/src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template Fri May 25 12:44:34 2018 -0700 @@ -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 @@ 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; diff -r 33a890c972c3 -r 69204b98dc3d src/java.base/unix/native/libnet/PlainSocketImpl.c --- a/src/java.base/unix/native/libnet/PlainSocketImpl.c Fri May 25 11:59:01 2018 -0700 +++ b/src/java.base/unix/native/libnet/PlainSocketImpl.c Fri May 25 12:44:34 2018 -0700 @@ -630,8 +630,8 @@ * 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 @@ 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); diff -r 33a890c972c3 -r 69204b98dc3d src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c --- a/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c Fri May 25 11:59:01 2018 -0700 +++ b/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c Fri May 25 12:44:34 2018 -0700 @@ -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 @@ 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 @@ 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) { diff -r 33a890c972c3 -r 69204b98dc3d src/java.base/unix/native/libnio/ch/IOUtil.c --- a/src/java.base/unix/native/libnio/ch/IOUtil.c Fri May 25 11:59:01 2018 -0700 +++ b/src/java.base/unix/native/libnio/ch/IOUtil.c Fri May 25 12:44:34 2018 -0700 @@ -120,7 +120,7 @@ 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 @@ 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 @@ 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 @@ return 0; } } - else if (errno == EAGAIN) + else if (errno == EAGAIN || errno == EWOULDBLOCK) return IOS_UNAVAILABLE; else if (errno == EINTR) return IOS_INTERRUPTED; diff -r 33a890c972c3 -r 69204b98dc3d src/java.base/unix/native/libnio/ch/ServerSocketChannelImpl.c --- a/src/java.base/unix/native/libnio/ch/ServerSocketChannelImpl.c Fri May 25 11:59:01 2018 -0700 +++ b/src/java.base/unix/native/libnio/ch/ServerSocketChannelImpl.c Fri May 25 12:44:34 2018 -0700 @@ -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 @@ } if (newfd < 0) { - if (errno == EAGAIN) + if (errno == EAGAIN || errno == EWOULDBLOCK) return IOS_UNAVAILABLE; if (errno == EINTR) return IOS_INTERRUPTED; diff -r 33a890c972c3 -r 69204b98dc3d src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c --- a/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c Fri May 25 11:59:01 2018 -0700 +++ b/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c Fri May 25 12:44:34 2018 -0700 @@ -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 @@ 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 @@ 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;