changeset 9800:dc1cab441d6b

Merge
author asaha
date Thu, 03 Apr 2014 10:03:06 -0700
parents 65e0a0183b1c f1e7b609c0e9
children 5efce41be1c8 e1481cf280ca
files
diffstat 5 files changed, 31 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/java/net/PlainDatagramSocketImpl.c	Wed Apr 02 16:13:24 2014 +0400
+++ b/src/solaris/native/java/net/PlainDatagramSocketImpl.c	Thu Apr 03 10:03:06 2014 -0700
@@ -509,8 +509,7 @@
         JNU_ThrowNullPointerException(env, "Null address in peek()");
     }
     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");
@@ -518,6 +517,8 @@
         } else if (ret == JVM_IO_ERR) {
             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");
             }
@@ -612,22 +613,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 == JVM_IO_ERR) {
+            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;
         } else if (ret == JVM_IO_INTR) {
             JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
@@ -831,23 +834,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 == JVM_IO_ERR) {
+                     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
                 } else if (ret == JVM_IO_INTR) {
                     JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
                                     "operation interrupted");
--- a/src/solaris/native/java/net/PlainSocketImpl.c	Wed Apr 02 16:13:24 2014 +0400
+++ b/src/solaris/native/java/net/PlainSocketImpl.c	Thu Apr 03 10:03:06 2014 -0700
@@ -704,11 +704,10 @@
         /* passing a timeout of 0 to poll will return immediately,
            but in the case of ServerSocket 0 means infinite. */
         if (timeout <= 0) {
-            ret = NET_Timeout(env, fd, -1);
+            ret = NET_Timeout(fd, -1);
         } else {
-            ret = NET_Timeout(env, fd, timeout);
+            ret = NET_Timeout(fd, timeout);
         }
-        JNU_CHECK_EXCEPTION(env);
         if (ret == 0) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                             "Accept timed out");
@@ -716,6 +715,8 @@
         } else if (ret == JVM_IO_ERR) {
             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", "Accept failed");
             }
--- a/src/solaris/native/java/net/SocketInputStream.c	Wed Apr 02 16:13:24 2014 +0400
+++ b/src/solaris/native/java/net/SocketInputStream.c	Thu Apr 03 10:03:06 2014 -0700
@@ -100,16 +100,16 @@
     }
 
     if (timeout) {
-        nread = NET_Timeout(env, fd, timeout);
+        nread = NET_Timeout(fd, timeout);
         if (nread <= 0) {
-            if ((*env)->ExceptionCheck(env)) {
-                // fall-through, to potentially free, then return
-            } else if (nread == 0) {
+            if (nread == 0) {
                 JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                             "Read timed out");
             } else if (nread == JVM_IO_ERR) {
                 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",
                                                   "select/poll failed");
--- a/src/solaris/native/java/net/bsd_close.c	Wed Apr 02 16:13:24 2014 +0400
+++ b/src/solaris/native/java/net/bsd_close.c	Thu Apr 03 10:03:06 2014 -0700
@@ -38,8 +38,6 @@
 #include <errno.h>
 #include <sys/poll.h>
 
-#include "jni_util.h"
-
 /*
  * Stack allocated by thread when doing blocking operation
  */
@@ -346,7 +344,7 @@
  * Auto restarts with adjusted timeout if interrupted by
  * signal other than our wakeup signal.
  */
-int NET_Timeout(JNIEnv *env, int s, long timeout) {
+int NET_Timeout(int s, long timeout) {
     long prevtime = 0, newtime;
     struct timeval t, *tp = &t;
     fd_set fds;
@@ -389,8 +387,7 @@
         int length = (howmany(s+1, NFDBITS)) * sizeof(int);
         fdsp = (fd_set *) calloc(1, length);
         if (fdsp == NULL) {
-            JNU_ThrowOutOfMemoryError(env, "NET_Select native heap allocation failed");
-            return 0;
+            return -1;   // errno will be set to ENOMEM
         }
         allocated = 1;
     }
--- a/src/solaris/native/java/net/linux_close.c	Wed Apr 02 16:13:24 2014 +0400
+++ b/src/solaris/native/java/net/linux_close.c	Thu Apr 03 10:03:06 2014 -0700
@@ -36,8 +36,6 @@
 #include <errno.h>
 #include <sys/poll.h>
 
-#include "jni.h"
-
 /*
  * Stack allocated by thread when doing blocking operation
  */
@@ -326,7 +324,7 @@
  * Auto restarts with adjusted timeout if interrupted by
  * signal other than our wakeup signal.
  */
-int NET_Timeout(JNIEnv *unused, int s, long timeout) {
+int NET_Timeout(int s, long timeout) {
     long prevtime = 0, newtime;
     struct timeval t;
     fdEntry_t *fdEntry = getFdEntry(s);