src/solaris/native/java/net/PlainDatagramSocketImpl.c

Print this page

        

@@ -499,11 +499,12 @@
     if (IS_NULL(addressObj)) {
         JNU_ThrowNullPointerException(env, "Null address in peek()");
         return -1;
     }
     if (timeout) {
-        int ret = NET_Timeout(fd, timeout);
+        int ret = NET_Timeout(env, fd, timeout);
+        JNU_CHECK_EXCEPTION_RETURN(env, -1);
         if (ret == 0) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                             "Peek timed out");
             return ret;
         } else if (ret == -1) {

@@ -592,11 +593,12 @@
         return -1;
     }
     packetBufferOffset = (*env)->GetIntField(env, packet, dp_offsetID);
     packetBufferLen = (*env)->GetIntField(env, packet, dp_bufLengthID);
     if (timeout) {
-        int ret = NET_Timeout(fd, timeout);
+        int ret = NET_Timeout(env, fd, timeout);
+        JNU_CHECK_EXCEPTION_RETURN(env, -1);
         if (ret == 0) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                             "Receive timed out");
             return -1;
         } else if (ret == -1) {

@@ -800,13 +802,15 @@
 
     do {
         retry = JNI_FALSE;
 
         if (timeout) {
-            int ret = NET_Timeout(fd, timeout);
+            int ret = NET_Timeout(env, fd, timeout);
             if (ret <= 0) {
-                if (ret == 0) {
+                if ((*env)->ExceptionCheck(env)) {
+                    // fall-through, to potentially free, then return
+                } else if (ret == 0) {
                     JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                                     "Receive timed out");
                 } else if (ret == -1) {
 #ifdef __linux__
                     if (errno == EBADF) {