< prev index next >
src/solaris/native/sun/nio/ch/IOUtil.c
Print this page
rev 13048 : 8203369: Check for both EAGAIN and EWOULDBLOCK error codes
Reviewed-by: alanb
@@ -1,7 +1,7 @@
/*
- * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -113,11 +113,11 @@
int tn = 0;
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;
return (tn > 0) ? JNI_TRUE : JNI_FALSE;
}
@@ -159,11 +159,11 @@
return IOS_EOF; /* EOF is -1 in javaland */
} else {
return 0;
}
}
- else if (errno == EAGAIN)
+ else if (errno == EAGAIN || errno == EWOULDBLOCK)
return IOS_UNAVAILABLE;
else if (errno == EINTR)
return IOS_INTERRUPTED;
else {
const char *msg = reading ? "Read failed" : "Write failed";
@@ -184,11 +184,11 @@
return IOS_EOF; /* EOF is -1 in javaland */
} else {
return 0;
}
}
- else if (errno == EAGAIN)
+ else if (errno == EAGAIN || errno == EWOULDBLOCK)
return IOS_UNAVAILABLE;
else if (errno == EINTR)
return IOS_INTERRUPTED;
else {
const char *msg = reading ? "Read failed" : "Write failed";
< prev index next >