[kaffe] CVS kaffe (dalibor): Resynced with GNU Classpath

Kaffe CVS cvs-commits at kaffe.org
Mon Feb 23 12:41:02 PST 2004


PatchSet 4450 
Date: 2004/02/23 20:12:37
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Classpath

2004-02-06  Mohan Embar  <gnustuff at thisiscool.com>

        * gnu/java/nio/DatagramChannelImpl.java
        (inChannelOperation): New field.
        (isInChannelOperation): New accessor.
        (setInChannelOperation): New modifier.
        (receive): Use capacity() - position() of destination
        buffer instead of remaining(). Set and reset our in channel operation indicator
 before and after delegating
        the receive to our datagram socket. Removed testing code.
        Update destination buffer's current position if it is
        backed by a byte array (hasArray() is true).
        (send): Set and reset our in channel operation indicator
        before and after delegating the send to our datagram socket.
        Removed testing code. Update source buffer's current position
        if it is backed by a byte array (hasArray() is true).
        * gnu/java/nio/SocketChannelImpl.java (read(ByteBuffer)):
        Use capacity() - position() of destination buffer instead
        of remaining().

Members: 
	ChangeLog:1.2030->1.2031 
	libraries/javalib/gnu/java/nio/DatagramChannelImpl.java:1.6->1.7 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2030 kaffe/ChangeLog:1.2031
--- kaffe/ChangeLog:1.2030	Mon Feb 23 20:00:41 2004
+++ kaffe/ChangeLog	Mon Feb 23 20:12:37 2004
@@ -1,5 +1,29 @@
 2004-02-23  Dalibor Topic <robilad at kaffe.org>
 
+	Resynced with GNU Classpath
+
+	2004-02-06  Mohan Embar  <gnustuff at thisiscool.com>
+
+        * gnu/java/nio/DatagramChannelImpl.java
+        (inChannelOperation): New field.
+        (isInChannelOperation): New accessor.
+        (setInChannelOperation): New modifier.
+        (receive): Use capacity() - position() of destination
+        buffer instead of remaining(). Set and reset our "in
+        channel operation indicator" before and after delegating
+        the receive to our datagram socket. Removed testing code.
+        Update destination buffer's current position if it is
+        backed by a byte array (hasArray() is true).
+        (send): Set and reset our "in channel operation indicator"
+        before and after delegating the send to our datagram socket.
+        Removed testing code. Update source buffer's current position
+        if it is backed by a byte array (hasArray() is true).
+        * gnu/java/nio/SocketChannelImpl.java (read(ByteBuffer)):
+        Use capacity() - position() of destination buffer instead
+        of remaining().
+
+2004-02-23  Dalibor Topic <robilad at kaffe.org>
+
         * kaffe/kaffevm/verify.c
         (typeErrorInCheckMethodCall): New static inline function.
         (TYPE_ERROR) Removed.
Index: kaffe/libraries/javalib/gnu/java/nio/DatagramChannelImpl.java
diff -u kaffe/libraries/javalib/gnu/java/nio/DatagramChannelImpl.java:1.6 kaffe/libraries/javalib/gnu/java/nio/DatagramChannelImpl.java:1.7
--- kaffe/libraries/javalib/gnu/java/nio/DatagramChannelImpl.java:1.6	Thu Jan  8 16:50:12 2004
+++ kaffe/libraries/javalib/gnu/java/nio/DatagramChannelImpl.java	Mon Feb 23 20:12:39 2004
@@ -57,6 +57,33 @@
 {
   private NIODatagramSocket socket;
   
+  /**
+   * Indicates whether this channel initiated whatever operation
+   * is being invoked on our datagram socket.
+   */
+  private boolean inChannelOperation;
+
+  /**
+   * Indicates whether our datagram socket should ignore whether
+   * we are set to non-blocking mode. Certain operations on our
+   * socket throw an <code>IllegalBlockingModeException</code> if
+   * we are in non-blocking mode, <i>except</i> if the operation
+   * is initiated by us.
+   */
+  public final boolean isInChannelOperation()
+  {
+    return inChannelOperation;
+  }
+  
+  /**
+   * Sets our indicator of whether we are initiating an I/O operation
+   * on our socket.
+   */
+  public final void setInChannelOperation(boolean b)
+  {
+    inChannelOperation = b;
+  }
+ 
   protected DatagramChannelImpl (SelectorProvider provider)
     throws IOException
   {
@@ -178,7 +205,7 @@
     try
       {
         DatagramPacket packet;
-        int len = dst.remaining();
+        int len = dst.capacity() - dst.position();
         
         if (dst.hasArray())
           {
@@ -196,23 +223,23 @@
         try
           {
             begin();
+            setInChannelOperation(true);
             socket.receive (packet);
             completed = true;
           }
         finally
           {
             end (completed);
+            setInChannelOperation(false);
           }
 
         if (!dst.hasArray())
           {
             dst.put (packet.getData(), packet.getOffset(), packet.getLength());
           }
-
-        // FIMXE: remove this testing code.
-        for (int i = 0; i < packet.getLength(); i++)
+        else
           {
-            System.out.println ("Byte " + i + " has value " + packet.getData() [packet.getOffset() + i]);
+            dst.position (dst.position() + packet.getLength());
           }
 
         return packet.getSocketAddress();
@@ -246,13 +273,25 @@
 
     DatagramPacket packet = new DatagramPacket (buffer, offset, len, target);
 
-    // FIMXE: remove this testing code.
-    for (int i = 0; i < packet.getLength(); i++)
+    boolean completed = false;
+    try
+      {
+        begin();
+        setInChannelOperation(true);
+        socket.send(packet);
+        completed = true;
+      }
+    finally
+      {
+        end (completed);
+        setInChannelOperation(false);
+      }
+      
+    if (src.hasArray())
       {
-        System.out.println ("Byte " + i + " has value " + packet.getData() [packet.getOffset() + i]);
+	src.position (src.position() + len);
       }
 
-    socket.send (packet);
     return len;
   }
 }




More information about the kaffe mailing list