From 6e708e358b39765cc67413d5112db7c41d27ee23 Mon Sep 17 00:00:00 2001 From: alanb Date: Fri, 4 Mar 2011 09:29:56 +0000 Subject: [PATCH] 6944810: (ch) Assert failure in sun.nio.ch.PendingIoCache.clearPendingIoMap [win] Reviewed-by: chegar --- .../nio/channels/AsynchronousFileChannel.java | 4 ++-- .../classes/sun/nio/ch/PendingIoCache.java | 7 ++++--- .../WindowsAsynchronousFileChannelImpl.java | 13 +++++++----- .../WindowsAsynchronousSocketChannelImpl.java | 4 ++-- test/ProblemList.txt | 21 ------------------- 5 files changed, 16 insertions(+), 33 deletions(-) diff --git a/src/share/classes/java/nio/channels/AsynchronousFileChannel.java b/src/share/classes/java/nio/channels/AsynchronousFileChannel.java index 4f4ac7f4a..3e90769d3 100644 --- a/src/share/classes/java/nio/channels/AsynchronousFileChannel.java +++ b/src/share/classes/java/nio/channels/AsynchronousFileChannel.java @@ -48,7 +48,7 @@ import java.util.Collections; * *

An asynchronous file channel does not have a current position * within the file. Instead, the file position is specified to each read and - * write methd that initiate asynchronous operations. A {@link CompletionHandler} + * write method that initiates asynchronous operations. A {@link CompletionHandler} * is specified as a parameter and is invoked to consume the result of the I/O * operation. This class also defines read and write methods that initiate * asynchronous operations, returning a {@link Future} to represent the pending @@ -73,7 +73,7 @@ import java.util.Collections; * which tasks are submitted to handle I/O events and dispatch to completion * handlers that consume the results of I/O operations on the channel. The * completion handler for an I/O operation initiated on a channel is guaranteed - * to be invoked by one threads in the thread pool (This ensures that the + * to be invoked by one of the threads in the thread pool (This ensures that the * completion handler is run by a thread with the expected identity). * Where an I/O operation completes immediately, and the initiating thread is * itself a thread in the thread pool, then the completion handler may be invoked diff --git a/src/windows/classes/sun/nio/ch/PendingIoCache.java b/src/windows/classes/sun/nio/ch/PendingIoCache.java index 3d78a733c..7a4b1e3e3 100644 --- a/src/windows/classes/sun/nio/ch/PendingIoCache.java +++ b/src/windows/classes/sun/nio/ch/PendingIoCache.java @@ -110,8 +110,7 @@ class PendingIoCache { if (closed) return; - // handle the case that where there are I/O operations that have - // not completed. + // handle case where I/O operations that have not completed. if (!pendingIoMap.isEmpty()) clearPendingIoMap(); @@ -132,7 +131,9 @@ class PendingIoCache { closePending = true; try { this.wait(50); - } catch (InterruptedException x) { } + } catch (InterruptedException x) { + Thread.currentThread().interrupt(); + } closePending = false; if (pendingIoMap.isEmpty()) return; diff --git a/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java b/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java index 694b23a34..824058759 100644 --- a/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java +++ b/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java @@ -439,6 +439,7 @@ public class WindowsAsynchronousFileChannelImpl address = ((DirectBuffer)buf).address(); } + boolean pending = false; try { begin(); @@ -449,6 +450,7 @@ public class WindowsAsynchronousFileChannelImpl n = readFile(handle, address, rem, position, overlapped); if (n == IOStatus.UNAVAILABLE) { // I/O is pending + pending = true; return; } else if (n == IOStatus.EOF) { result.setResult(n); @@ -460,14 +462,15 @@ public class WindowsAsynchronousFileChannelImpl // failed to initiate read result.setFailure(toIOException(x)); } finally { + if (!pending) { + // release resources + if (overlapped != 0L) + ioCache.remove(overlapped); + releaseBufferIfSubstituted(); + } end(); } - // release resources - if (overlapped != 0L) - ioCache.remove(overlapped); - releaseBufferIfSubstituted(); - // invoke completion handler Invoker.invoke(result); } diff --git a/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java b/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java index 28d3c0745..2cc9cf026 100644 --- a/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java +++ b/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java @@ -239,14 +239,14 @@ class WindowsAsynchronousSocketChannelImpl result.setResult(null); } } catch (Throwable x) { + if (overlapped != 0L) + ioCache.remove(overlapped); exc = x; } finally { end(); } if (exc != null) { - if (overlapped != 0L) - ioCache.remove(overlapped); closeChannel(); result.setFailure(toIOException(exc)); } diff --git a/test/ProblemList.txt b/test/ProblemList.txt index 62c19030b..27518785b 100644 --- a/test/ProblemList.txt +++ b/test/ProblemList.txt @@ -380,30 +380,9 @@ java/io/File/MaxPathLength.java windows-all # jdk_nio -# 6944810 -java/nio/channels/FileChannel/ReleaseOnCloseDeadlock.java windows-all - # 6963118 java/nio/channels/Selector/Wakeup.java windows-all -# The asynchronous I/O implementation on Windows requires Windows XP or newer. -# We can remove the following once all Windows 2000 machines have been -# decommissioned. -java/nio/channels/AsynchronousChannelGroup/Basic.java windows-5.0 -java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java windows-5.0 -java/nio/channels/AsynchronousChannelGroup/Identity.java windows-5.0 -java/nio/channels/AsynchronousChannelGroup/Restart.java windows-5.0 -java/nio/channels/AsynchronousChannelGroup/Unbounded.java windows-5.0 -java/nio/channels/AsynchronousDatagramChannel/Basic.java windows-5.0 -java/nio/channels/AsynchronousFileChannel/Lock.java windows-5.0 -java/nio/channels/AsynchronousServerSocketChannel/Basic.java windows-5.0 -java/nio/channels/AsynchronousServerSocketChannel/WithSecurityManager.java windows-5.0 -java/nio/channels/AsynchronousSocketChannel/Basic.java windows-5.0 -java/nio/channels/AsynchronousSocketChannel/DieBeforeComplete.java windows-5.0 -java/nio/channels/AsynchronousSocketChannel/Leaky.java windows-5.0 -java/nio/channels/AsynchronousSocketChannel/StressLoopback.java windows-5.0 -java/nio/channels/Channels/Basic2.java windows-5.0 - # 6959891 com/sun/nio/sctp/SctpChannel/SocketOptionTests.java -- GitLab