changeset 3842:7b6ad3027f3d

7023403: (ch) sun.nio.ch.SolarisEventPort.startPoll failed with AssertionError Reviewed-by: forax
author alanb
date Fri, 04 Mar 2011 21:26:50 +0000
parents 259011d14d48
children 28bedf6eba87
files src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java test/java/nio/channels/AsynchronousSocketChannel/Basic.java
diffstat 2 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java	Fri Mar 04 09:33:05 2011 +0000
+++ b/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java	Fri Mar 04 21:26:50 2011 +0000
@@ -137,7 +137,7 @@
         return port;
     }
 
-    // register for events if there are outstanding I/O operations
+    // register events for outstanding I/O operations, caller already owns updateLock
     private void updateEvents() {
         assert Thread.holdsLock(updateLock);
         int events = 0;
@@ -149,6 +149,13 @@
             port.startPoll(fdVal, events);
     }
 
+    // register events for outstanding I/O operations
+    private void lockAndUpdateEvents() {
+        synchronized (updateLock) {
+            updateEvents();
+        }
+    }
+
     // invoke to finish read and/or write operations
     private void finish(boolean mayInvokeDirect,
                         boolean readable,
@@ -402,9 +409,8 @@
             exc = x;
         } finally {
             // restart poll in case of concurrent write
-            synchronized (updateLock) {
-                updateEvents();
-            }
+            if (!(exc instanceof AsynchronousCloseException))
+                lockAndUpdateEvents();
             end();
         }
 
@@ -598,9 +604,8 @@
             exc = x;
         } finally {
             // restart poll in case of concurrent write
-            synchronized (updateLock) {
-                updateEvents();
-            }
+            if (!(exc instanceof AsynchronousCloseException))
+                lockAndUpdateEvents();
             end();
         }
 
--- a/test/java/nio/channels/AsynchronousSocketChannel/Basic.java	Fri Mar 04 09:33:05 2011 +0000
+++ b/test/java/nio/channels/AsynchronousSocketChannel/Basic.java	Fri Mar 04 21:26:50 2011 +0000
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4607272 6842687 6878369
+ * @bug 4607272 6842687 6878369 6944810 7023403
  * @summary Unit test for AsynchronousSocketChannel
  * @run main/timeout=600 Basic
  */