harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r921764 - in /harmony/enhanced/classlib/trunk/modules/nio/src: main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java
Date Thu, 11 Mar 2010 10:01:46 GMT
Author: hindessm
Date: Thu Mar 11 10:01:46 2010
New Revision: 921764

URL: http://svn.apache.org/viewvc?rev=921764&view=rev
Log:
Applying patches from "[#HARMONY-6375] [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel".

Modified:
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
    harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java?rev=921764&r1=921763&r2=921764&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
Thu Mar 11 10:01:46 2010
@@ -119,7 +119,6 @@ public class ServerSocketChannelImpl ext
             begin();
 
             synchronized (acceptLock) {
-                synchronized (blockingLock()) {
                     boolean isBlocking = isBlocking();
                     if (!isBlocking) {
                         // for non blocking mode, use select to see whether
@@ -145,7 +144,6 @@ public class ServerSocketChannelImpl ext
                             // mode.
                         }
                     } while (isBlocking);
-                }
             }
         } finally {
             end(socketGot.isConnected());

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java?rev=921764&r1=921763&r2=921764&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java
Thu Mar 11 10:01:46 2010
@@ -586,5 +586,33 @@ public class ServerSocketChannelTest ext
         serverChannel.close();
     }
 
-    
+    /**
+     * Regression test for HARMONY-6375
+     */
+    public void test_accept_configureBlocking() throws Exception {
+        InetSocketAddress localAddr = new InetSocketAddress("localhost", 0);
+        serverChannel.socket().bind(localAddr);
+
+        // configure the channel non-blocking 
+        // when it is accepting in main thread
+        new Thread() {
+            public void run() {
+                try {
+                    Thread.sleep(TIME_UNIT);
+                    serverChannel.configureBlocking(false);
+                    serverChannel.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }.start();
+
+        try {
+            serverChannel.accept();
+            fail("should throw AsynchronousCloseException");
+        } catch (AsynchronousCloseException e) {
+            // expected
+        }
+        serverChannel.close();
+    }
 }



Mime
View raw message