You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gh...@apache.org on 2006/07/06 14:18:57 UTC

svn commit: r419532 - /incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java

Author: gharley
Date: Thu Jul  6 05:18:56 2006
New Revision: 419532

URL: http://svn.apache.org/viewvc?rev=419532&view=rev
Log:
HARMONY 776 : [nio] Refine several methods of o.a.h.nio.internal.ServerSocketChannelImpl

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java?rev=419532&r1=419531&r2=419532&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java Thu Jul  6 05:18:56 2006
@@ -41,7 +41,7 @@
         FileDescriptorHandler {
 
     // ----------------------------------------------------
-    // Class Variables
+    // Class variables
     // ----------------------------------------------------
 
     // status un-init, not initialized.
@@ -73,9 +73,6 @@
     // lock for accept
     private final Object acceptLock = new Object();
 
-    // lock for status
-    // final Object statusLock = new Object();
-
     // ----------------------------------------------------
     // Constructor
     // ----------------------------------------------------
@@ -113,7 +110,7 @@
         if (!isOpen()) {
             throw new ClosedChannelException();
         }
-        if (!isBound || !socket.isBound()) {
+        if (!isBound) {
             throw new NotYetBoundException();
         }
 
@@ -168,7 +165,9 @@
      */
     protected void implConfigureBlocking(boolean blockingMode)
             throws IOException {
-        Platform.getNetworkSystem().setNonBlocking(getFD(), blockingMode);
+        // Do nothing here. For real accept() operation in nonblocking mode,
+        // it uses INetworkSystem.select. Whether a channel is blocking can be
+        // decided by isBlocking() method.
     }
 
     /*
@@ -176,23 +175,23 @@
      * @see java.nio.channels.spi.AbstractSelectableChannel#implCloseSelectableChannel()
      */
     synchronized protected void implCloseSelectableChannel() throws IOException {
-        status = SERVER_STATUS_CLOSED;     
+        status = SERVER_STATUS_CLOSED;
         if (!socket.isClosed()) {
             socket.close();
         }
     }
 
-    // ----------------------------------------------------
-    // Adapter classes.
-    // ----------------------------------------------------
-
     /*
-     * get the fd
+     * Gets the FileDescriptor
      */
     public FileDescriptor getFD() {
         return fd;
     }
 
+    // ----------------------------------------------------
+    // Adapter classes.
+    // ----------------------------------------------------
+
     /*
      * The adapter class of ServerSocket.
      */
@@ -206,7 +205,7 @@
          * The Constructor.
          */
         ServerSocketAdapter(SocketImpl impl,
-                ServerSocketChannelImpl aChannelImpl){
+                ServerSocketChannelImpl aChannelImpl) {
             super(impl);
             this.channelImpl = aChannelImpl;
         }
@@ -224,15 +223,15 @@
          * @see java.net.ServerSocket#accept()
          * 
          * If the channel is in non-blocking mode and there is no connection
-         * ready to be accepted, invoking this method will causes an
+         * ready to be accepted, invoking this method will cause an
          * IllegalBlockingModeException.
          */
         public Socket accept() throws IOException {
-            if (!isBound || !socket.isBound()) {
+            if (!isBound) {
                 throw new IllegalBlockingModeException();
             }
             SocketChannel sc = channelImpl.accept();
-            if(null == sc){
+            if (null == sc) {
                 throw new IllegalBlockingModeException();
             }
             return sc.socket();
@@ -294,7 +293,7 @@
          */
         public void close() throws IOException {
             synchronized (channelImpl) {
-                if(channelImpl.isOpen()){
+                if (channelImpl.isOpen()) {
                     channelImpl.close();
                 } else {
                     super.close();