This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch FYI: networking fixes from GNU Classpath


I just migrated the following approved patches from GNU Classpath to GCC
HEAD and the 4.1 branch.

AG


2005-12-27  Tom Tromey  <tromey@redhat.com>

	* gnu/java/nio/SelectorImpl.java: Added import.

2005-12-26  Anthony Green  <green@redhat.com>

        * java/net/Socket.java (connect): Don't close the socket on
        exceptions.

        * gnu/java/nio/SocketChannelImpl.java (read): Compute the right amount
        of data to read (dst.remaining()).
        * gnu/java/nio/DatagramChannelImpl.java (receive): Ditto.

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



Index: java/net/Socket.java
===================================================================
--- java/net/Socket.java	(revision 109112)
+++ java/net/Socket.java	(working copy)
@@ -437,25 +437,7 @@
     if (! isBound())
       bind(null);
 
-    try
-      {
-	getImpl().connect(endpoint, timeout);
-      }
-    catch (IOException exception)
-      {
-	close();
-	throw exception;
-      }
-    catch (RuntimeException exception)
-      {
-	close();
-	throw exception;
-      }
-    catch (Error error)
-      {
-	close();
-	throw error;
-      }
+    getImpl().connect(endpoint, timeout);
   }
 
   /**
Index: gnu/java/nio/SelectorImpl.java
===================================================================
--- gnu/java/nio/SelectorImpl.java	(revision 109112)
+++ gnu/java/nio/SelectorImpl.java	(working copy)
@@ -43,6 +43,7 @@
 import java.nio.channels.SelectableChannel;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
+import java.nio.channels.SocketChannel;
 import java.nio.channels.spi.AbstractSelectableChannel;
 import java.nio.channels.spi.AbstractSelector;
 import java.nio.channels.spi.SelectorProvider;
@@ -284,19 +285,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.
Index: gnu/java/nio/SocketChannelImpl.java
===================================================================
--- gnu/java/nio/SocketChannelImpl.java	(revision 109112)
+++ gnu/java/nio/SocketChannelImpl.java	(working copy)
@@ -220,7 +220,7 @@
     int offset = 0;
     InputStream input = socket.getInputStream();
     int available = input.available();
-    int len = dst.capacity() - dst.position();
+    int len = dst.remaining();
 	
     if ((! isBlocking()) && available == 0)
       return 0;
Index: gnu/java/nio/DatagramChannelImpl.java
===================================================================
--- gnu/java/nio/DatagramChannelImpl.java	(revision 109112)
+++ gnu/java/nio/DatagramChannelImpl.java	(working copy)
@@ -201,7 +201,7 @@
     try
       {
         DatagramPacket packet;
-        int len = dst.capacity() - dst.position();
+        int len = dst.remaining();
         
         if (dst.hasArray())
           {



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]