diff --git a/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java b/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java index 13e4ad36434..37caeeb9bce 100644 --- a/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java +++ b/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java @@ -137,7 +137,7 @@ class UnixAsynchronousSocketChannelImpl 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 @@ class UnixAsynchronousSocketChannelImpl 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 @@ class UnixAsynchronousSocketChannelImpl exc = x; } finally { // restart poll in case of concurrent write - synchronized (updateLock) { - updateEvents(); - } + if (!(exc instanceof AsynchronousCloseException)) + lockAndUpdateEvents(); end(); } @@ -598,9 +604,8 @@ class UnixAsynchronousSocketChannelImpl exc = x; } finally { // restart poll in case of concurrent write - synchronized (updateLock) { - updateEvents(); - } + if (!(exc instanceof AsynchronousCloseException)) + lockAndUpdateEvents(); end(); } diff --git a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java index 9f67fc37113..afe61d6d80a 100644 --- a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java +++ b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java @@ -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 */