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

Kaffe CVS cvs-commits at kaffe.org
Mon Feb 23 14:57:05 PST 2004


PatchSet 4454 
Date: 2004/02/23 22:38:46
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Classpath

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/SocketChannelImpl.java
        (connect): Set and reset our socket's PlainSocketImpl's "in channel
operation" indicator before and after delegating the operation to
        our socket.

Members: 
	ChangeLog:1.2034->1.2035 
	libraries/javalib/gnu/java/nio/SocketChannelImpl.java:1.10->1.11 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2034 kaffe/ChangeLog:1.2035
--- kaffe/ChangeLog:1.2034	Mon Feb 23 22:34:04 2004
+++ kaffe/ChangeLog	Mon Feb 23 22:38:46 2004
@@ -4,6 +4,19 @@
 
 	2004-02-06  Mohan Embar  <gnustuff at thisiscool.com>
 
+        * gnu/java/nio/SocketChannelImpl.java
+        (connect): Set and reset our socket's PlainSocketImpl's "in channel
+        operation" indicator before and after delegating the operation to
+        our socket.
+        (read): Likewise.
+        (write): Likewise.
+
+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/ServerSocketChannelImpl.java
         (accept): Set and reset our server socket's PlainSocketImpl's
         "in channel operation" indicator before and after delegating
Index: kaffe/libraries/javalib/gnu/java/nio/SocketChannelImpl.java
diff -u kaffe/libraries/javalib/gnu/java/nio/SocketChannelImpl.java:1.10 kaffe/libraries/javalib/gnu/java/nio/SocketChannelImpl.java:1.11
--- kaffe/libraries/javalib/gnu/java/nio/SocketChannelImpl.java:1.10	Thu Jan  8 17:25:26 2004
+++ kaffe/libraries/javalib/gnu/java/nio/SocketChannelImpl.java	Mon Feb 23 22:38:47 2004
@@ -1,5 +1,5 @@
 /* SocketChannelImpl.java -- 
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -136,23 +136,35 @@
     if (((InetSocketAddress) remote).isUnresolved())
       throw new UnresolvedAddressException();
     
-    if (isBlocking())
-      {
-        // Do blocking connect.
-        socket.connect (remote);
-        return true;
-      }
-
-    // Do non-blocking connect.
     try
       {
-        socket.connect (remote, NIOConstants.DEFAULT_TIMEOUT);
-        return true;
+        socket.getPlainSocketImpl().setInChannelOperation(true);
+          // indicate that a channel is initiating the accept operation
+          // so that the socket ignores the fact that we might be in
+          // non-blocking mode.
+        
+        if (isBlocking())
+          {
+            // Do blocking connect.
+            socket.connect (remote);
+            return true;
+          }
+
+        // Do non-blocking connect.
+        try
+          {
+            socket.connect (remote, NIOConstants.DEFAULT_TIMEOUT);
+            return true;
+          }
+        catch (SocketTimeoutException e)
+          {
+            connectionPending = true;
+            return false;
+          }
       }
-    catch (SocketTimeoutException e)
+    finally
       {
-        connectionPending = true;
-        return false;
+        socket.getPlainSocketImpl().setInChannelOperation(false);
       }
   }
     
@@ -162,7 +174,7 @@
     if (!isOpen())
       throw new ClosedChannelException();
     
-    if (!connectionPending)
+    if (!isConnected() && !connectionPending)
       throw new NoConnectionPendingException();
     
     if (isConnected())
@@ -214,7 +226,7 @@
     int offset = 0;
     InputStream input = socket.getInputStream();
     int available = input.available();
-    int len = dst.remaining();
+    int len = dst.capacity() - dst.position();
 	
     if (available == 0)
       return 0;
@@ -238,12 +250,14 @@
     try
       {
         begin();
+        socket.getPlainSocketImpl().setInChannelOperation(true);
         readBytes = input.read (data, offset, len);
         completed = true;
       }
     finally
       {
         end (completed);
+        socket.getPlainSocketImpl().setInChannelOperation(false);
       }
 
     if (readBytes > 0)
@@ -301,7 +315,20 @@
       }
 
     OutputStream output = socket.getOutputStream();
-    output.write (data, offset, len);
+    boolean completed = false;
+
+    try
+      {
+        begin();
+        socket.getPlainSocketImpl().setInChannelOperation(true);
+        output.write (data, offset, len);
+        completed = true;
+      }
+    finally
+      {
+        end (completed);
+        socket.getPlainSocketImpl().setInChannelOperation(false);
+      }
 
     if (src.hasArray())
       {




More information about the kaffe mailing list