classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] Patch: fix OP_CONNECT selects


From: Anthony Green
Subject: [cp-patches] Patch: fix OP_CONNECT selects
Date: Mon, 26 Dec 2005 18:02:01 -0800

We weren't properly recording OP_CONNECT events in our select routine.

After coming up with this, I discovered that this is basically the same
solution that Stanley Brown came up with over a year ago... 
http://gcc.gnu.org/ml/java/2004-09/msg00130.html


2005-12-26  Anthony Green  <address@hidden>

        * gnu/java/nio/SelectorImpl.java (select): Handle OP_CONNECT
        properly.

        
--- gnu/java/nio/SelectorImpl.java~     2005-10-28 17:36:04.000000000 -0400
+++ gnu/java/nio/SelectorImpl.java      2005-12-26 16:33:03.000000000 -0500
@@ -284,19 +284,18 @@
                 // Set new ready write ops
                 for (int i = 0; i < write.length; i++)
                   {
-                    if (key.getNativeFD() == write[i])
-                      {
-                        ops = ops | SelectionKey.OP_WRITE;
-
-        //                 if (key.channel ().isConnected ())
-        //                   {
-        //                     ops = ops | SelectionKey.OP_WRITE;
-        //                   }
-        //                 else
-        //                   {
-        //                     ops = ops | SelectionKey.OP_CONNECT;
-        //                   }
-                     }
+                   if (key.getNativeFD() == write[i])
+                     {
+                       if (key.channel() instanceof SocketChannel)
+                         {
+                           if ( ((SocketChannel)key.channel()).isConnected ())
+                             ops = ops | SelectionKey.OP_WRITE;
+                           else
+                             ops = ops | SelectionKey.OP_CONNECT;
+                         }
+                       else
+                         ops = ops | SelectionKey.OP_WRITE;
+                     }
                   }
 
                 // FIXME: We dont handle exceptional file descriptors yet.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]