[PATCH] 7052549 "(aio) AssertionError in sun.nio.ch.PendingIoCache.clearPendingIoMap (win)"

Yuri Gaevsky ygaevsky at azulsystems.com
Thu Oct 10 13:28:13 PDT 2013


Hello,

I'm trying to follow [1] in order to propose a patch for JDK-7052549 [2].

The code in clearPendingIoMap()  doesn't use 'synchronized' access to internal
data as all other methods do and the 'assert Thread.holdsLock(this)' statement
in the method can fail when "-esa" command-line option enabled. The proposed
patch moves all accesses to 'pendingIoMap' and 'closePending' under synchronized
block, and removes the 'assert !result.isDone()' statement.

The patch has been verified by JCK testrun with '-esa' option.

Thanks,
Yuri Gaevsky,
Azul Systems, Inc.

[1]  http://openjdk.java.net/contribute/
[2] https://bugs.openjdk.java.net/browse/JDK-7052549

diff --git a/src/windows/classes/sun/nio/ch/PendingIoCache.java b/src/windows/classes/sun/nio/ch/PendingIoCache.java
--- a/src/windows/classes/sun/nio/ch/PendingIoCache.java
+++ b/src/windows/classes/sun/nio/ch/PendingIoCache.java
@@ -125,38 +125,38 @@
     }
 
     private void clearPendingIoMap() {
-        assert Thread.holdsLock(this);
+        synchronized (this) {
+            // wait up to 50ms for the I/O operations to complete
+            closePending = true;
+            try {
+                this.wait(50);
+            } catch (InterruptedException x) {
+                Thread.currentThread().interrupt();
+            }
+            closePending = false;
 
-        // wait up to 50ms for the I/O operations to complete
-        closePending = true;
-        try {
-            this.wait(50);
-        } catch (InterruptedException x) {
-            Thread.currentThread().interrupt();
+            // cause all pending I/O operations to fail
+            // simulate the failure of all pending I/O operations.
+            if (!pendingIoMap.isEmpty()) {
+                for (Long ov: pendingIoMap.keySet()) {
+                    PendingFuture<?,?> result = pendingIoMap.get(ov);
+
+                    // make I/O port aware of the stale OVERLAPPED structure
+                    Iocp iocp = (Iocp)((Groupable)result.channel()).group();
+                    iocp.makeStale(ov);
+
+                    // execute a task that invokes the result handler's failed method
+                    final Iocp.ResultHandler rh = (Iocp.ResultHandler)result.getContext();
+                    Runnable task = new Runnable() {
+                        public void run() {
+                            rh.failed(-1, new AsynchronousCloseException());
+                        }
+                    };
+                    iocp.executeOnPooledThread(task);
+                }
+                pendingIoMap.clear();
+            }
         }
-        closePending = false;
-        if (pendingIoMap.isEmpty())
-            return;
-
-        // cause all pending I/O operations to fail
-        // simulate the failure of all pending I/O operations.
-        for (Long ov: pendingIoMap.keySet()) {
-            PendingFuture<?,?> result = pendingIoMap.get(ov);
-            assert !result.isDone();
-
-            // make I/O port aware of the stale OVERLAPPED structure
-            Iocp iocp = (Iocp)((Groupable)result.channel()).group();
-            iocp.makeStale(ov);
-
-            // execute a task that invokes the result handler's failed method
-            final Iocp.ResultHandler rh = (Iocp.ResultHandler)result.getContext();
-            Runnable task = new Runnable() {
-                public void run() {
-                    rh.failed(-1, new AsynchronousCloseException());
-                }
-            };
-            iocp.executeOnPooledThread(task);
-        }
-        pendingIoMap.clear();
     }
 }
+


More information about the nio-dev mailing list