Merge
authormullan
Mon, 22 Sep 2008 11:26:17 -0400
changeset 1338 b928fe1ab866
parent 1336 43c762ac4fdd (diff)
parent 1337 e8d6cef36199 (current diff)
child 1339 5fb372f1d51f
child 1452 6cd84bc82e68
Merge
jdk/src/share/classes/org/jcp/xml/dsig/internal/package.html
--- a/jdk/src/share/classes/java/net/AbstractPlainSocketImpl.java	Mon Sep 22 10:43:17 2008 -0400
+++ b/jdk/src/share/classes/java/net/AbstractPlainSocketImpl.java	Mon Sep 22 11:26:17 2008 -0400
@@ -308,6 +308,12 @@
             FileDescriptor fd = acquireFD();
             try {
                 socketConnect(address, port, timeout);
+                /* socket may have been closed during poll/select */
+                synchronized (fdLock) {
+                    if (closePending) {
+                        throw new SocketException ("Socket closed");
+                    }
+                }
                 // If we have a ref. to the Socket, then sets the flags
                 // created, bound & connected to true.
                 // This is normally done in Socket.connect() but some
--- a/jdk/src/solaris/native/java/net/PlainSocketImpl.c	Mon Sep 22 10:43:17 2008 -0400
+++ b/jdk/src/solaris/native/java/net/PlainSocketImpl.c	Mon Sep 22 11:26:17 2008 -0400
@@ -491,27 +491,6 @@
         return;
     }
 
-    /*
-     * The socket may have been closed (dup'ed) while we were
-     * poll/select. In that case SO_ERROR will return 0 making
-     * it appear that the connection has been established.
-     * To avoid any race conditions we therefore grab the
-     * fd lock, check if the socket has been closed, and
-     * set the various fields whilst holding the lock
-     */
-    fdLock = (*env)->GetObjectField(env, this, psi_fdLockID);
-    (*env)->MonitorEnter(env, fdLock);
-
-    if ((*env)->GetBooleanField(env, this, psi_closePendingID)) {
-
-        /* release fdLock */
-        (*env)->MonitorExit(env, fdLock);
-
-        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
-                            "Socket closed");
-        return;
-    }
-
     (*env)->SetIntField(env, fdObj, IO_fd_fdID, fd);
 
     /* set the remote peer address and port */
@@ -536,11 +515,6 @@
             (*env)->SetIntField(env, this, psi_localportID, localport);
         }
     }
-
-    /*
-     * Finally release fdLock
-     */
-    (*env)->MonitorExit(env, fdLock);
 }
 
 /*