Jeroen helped flush a brain fart out of my head; this patch fixes the
definition of `isConnected' in SocketChannel -- if we have a connection
pending, meaning that we initiated a nonblocking connect, which did not
succeed immediately, and finishConnect was not called after the
connection completes, then we should return false for `isConnected.'

2006-09-20  Casey Marshall  <[EMAIL PROTECTED]>

        * gnu/java/nio/SocketChannelImpl.java (finishConnect): don't
        call `isConnected.'
        (isConnected): return false if `connectionPending' is true.

Committed.
### Eclipse Workspace Patch 1.0
#P classpath
Index: ChangeLog
===================================================================
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.8577
diff -u -r1.8577 ChangeLog
--- ChangeLog   20 Sep 2006 18:26:24 -0000      1.8577
+++ ChangeLog   20 Sep 2006 21:04:45 -0000
@@ -1,3 +1,9 @@
+2006-09-20  Casey Marshall  <[EMAIL PROTECTED]>
+
+       * gnu/java/nio/SocketChannelImpl.java (finishConnect): don't
+       call `isConnected.'
+       (isConnected): return false if `connectionPending' is true.
+
 2006-09-20  Francis Kung  <[EMAIL PROTECTED]>
 
        PR 29011
Index: gnu/java/nio/SocketChannelImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/nio/SocketChannelImpl.java,v
retrieving revision 1.30
diff -u -r1.30 SocketChannelImpl.java
--- gnu/java/nio/SocketChannelImpl.java 17 Sep 2006 07:31:41 -0000      1.30
+++ gnu/java/nio/SocketChannelImpl.java 20 Sep 2006 21:04:45 -0000
@@ -175,14 +175,15 @@
     connectionPending = !connected;
     return connected;
   }
-    
-  public boolean finishConnect ()
+
+  public boolean finishConnect()
     throws IOException
   {
     if (!isOpen())
       throw new ClosedChannelException();
-    
-    if (isConnected())
+
+    InetSocketAddress remote = channel.getPeerAddress();
+    if (remote != null)
       {
         connectionPending = false;
         return true;
@@ -196,6 +197,10 @@
 
   public boolean isConnected()
   {
+    // Wait until finishConnect is called before transitioning to
+    // connected.
+    if (connectionPending)
+      return false;
     try
       {
         InetSocketAddress remote = channel.getPeerAddress();

Reply via email to