--- a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c Fri Feb 28 13:38:51 2014 +0100
+++ b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c Tue Mar 04 13:27:55 2014 +0000
@@ -501,8 +501,7 @@
return -1;
}
if (timeout) {
- int ret = NET_Timeout(env, fd, timeout);
- JNU_CHECK_EXCEPTION_RETURN(env, -1);
+ int ret = NET_Timeout(fd, timeout);
if (ret == 0) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
"Peek timed out");
@@ -510,6 +509,8 @@
} else if (ret == -1) {
if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+ } else if (errno == ENOMEM) {
+ JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Peek failed");
}
@@ -595,22 +596,24 @@
packetBufferOffset = (*env)->GetIntField(env, packet, dp_offsetID);
packetBufferLen = (*env)->GetIntField(env, packet, dp_bufLengthID);
if (timeout) {
- int ret = NET_Timeout(env, fd, timeout);
- JNU_CHECK_EXCEPTION_RETURN(env, -1);
+ int ret = NET_Timeout(fd, timeout);
if (ret == 0) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
"Receive timed out");
return -1;
} else if (ret == -1) {
+ if (errno == ENOMEM) {
+ JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
#ifdef __linux__
- if (errno == EBADF) {
+ } else if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
+#else
+ } else {
+ JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+#endif
}
-#else
- JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
-#endif
return -1;
}
}
@@ -804,23 +807,24 @@
retry = JNI_FALSE;
if (timeout) {
- int ret = NET_Timeout(env, fd, timeout);
+ int ret = NET_Timeout(fd, timeout);
if (ret <= 0) {
- if ((*env)->ExceptionCheck(env)) {
- // fall-through, to potentially free, then return
- } else if (ret == 0) {
+ if (ret == 0) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
"Receive timed out");
} else if (ret == -1) {
+ if (errno == ENOMEM) {
+ JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
#ifdef __linux__
- if (errno == EBADF) {
+ } else if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
- } else {
- NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
- }
+ } else {
+ NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
#else
- JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+ } else {
+ JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
#endif
+ }
}
if (mallocedPacket) {