# HG changeset patch # User igerasim # Date 1527290382 25200 # Fri May 25 16:19:42 2018 -0700 # Node ID d377f0b2d8a5eecba814e97c161bf2e22899d61e # Parent f0060cc015ba7ef6ce26543e871ad4a59cb2ab6a 8203369: Check for both EAGAIN and EWOULDBLOCK error codes Reviewed-by: alanb diff --git a/make/src/native/genconstants/fs/genUnixConstants.c b/make/src/native/genconstants/fs/genUnixConstants.c --- a/make/src/native/genconstants/fs/genUnixConstants.c +++ b/make/src/native/genconstants/fs/genUnixConstants.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, 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 @@ -113,6 +113,7 @@ DEF(ENOTEMPTY); DEF(ENOSPC); DEF(EAGAIN); + DEF(EWOULDBLOCK); DEF(ENOSYS); DEF(ELOOP); DEF(EROFS); diff --git a/src/solaris/classes/sun/nio/fs/LinuxWatchService.java b/src/solaris/classes/sun/nio/fs/LinuxWatchService.java --- a/src/solaris/classes/sun/nio/fs/LinuxWatchService.java +++ b/src/solaris/classes/sun/nio/fs/LinuxWatchService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, 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 @@ -317,7 +317,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; } @@ -365,7 +365,7 @@ if (shutdown) break; } catch (UnixException x) { - if (x.errno() != UnixConstants.EAGAIN) + if (x.errno() != EAGAIN && x.errno() != EWOULDBLOCK) throw x; } } diff --git a/src/solaris/native/java/net/PlainSocketImpl.c b/src/solaris/native/java/net/PlainSocketImpl.c --- a/src/solaris/native/java/net/PlainSocketImpl.c +++ b/src/solaris/native/java/net/PlainSocketImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -693,8 +693,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; @@ -738,12 +738,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 (timeout) { jlong currTime = JVM_CurrentTimeMillis(env, 0); timeout -= (currTime - prevTime); diff --git a/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c b/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c --- a/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c +++ b/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, 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 @@ -162,7 +162,7 @@ retry = JNI_FALSE; n = recvfrom(fd, buf, len, 0, (struct sockaddr *)&sa, &sa_len); if (n < 0) { - if (errno == EWOULDBLOCK) { + if (errno == EAGAIN || errno == EWOULDBLOCK) { return IOS_UNAVAILABLE; } if (errno == EINTR) { @@ -239,7 +239,7 @@ n = sendto(fd, buf, len, 0, (struct sockaddr *)&sa, sa_len); if (n < 0) { - if (errno == EAGAIN) { + if (errno == EAGAIN || errno == EWOULDBLOCK) { return IOS_UNAVAILABLE; } if (errno == EINTR) { diff --git a/src/solaris/native/sun/nio/ch/IOUtil.c b/src/solaris/native/sun/nio/ch/IOUtil.c --- a/src/solaris/native/sun/nio/ch/IOUtil.c +++ b/src/solaris/native/sun/nio/ch/IOUtil.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, 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 @@ -115,7 +115,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; @@ -161,7 +161,7 @@ return 0; } } - else if (errno == EAGAIN) + else if (errno == EAGAIN || errno == EWOULDBLOCK) return IOS_UNAVAILABLE; else if (errno == EINTR) return IOS_INTERRUPTED; @@ -186,7 +186,7 @@ return 0; } } - else if (errno == EAGAIN) + else if (errno == EAGAIN || errno == EWOULDBLOCK) return IOS_UNAVAILABLE; else if (errno == EINTR) return IOS_INTERRUPTED; diff --git a/src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c b/src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c --- a/src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c +++ b/src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2008, 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 @@ -111,7 +111,7 @@ if (newfd < 0) { free((void *)sa); - if (errno == EAGAIN) + if (errno == EAGAIN || errno == EWOULDBLOCK) return IOS_UNAVAILABLE; if (errno == EINTR) return IOS_INTERRUPTED; diff --git a/src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c b/src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c --- a/src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c +++ b/src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2015, 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 @@ -440,7 +440,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; @@ -585,7 +585,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;