8334719: (se) Deferred close of SelectableChannel may result in a Selector doing the final close before concurrent I/O on channel has completed

Co-authored-by: Alan Bateman <alanb@openjdk.org>
Reviewed-by: alanb, dfuchs
This commit is contained in:
Jaikiran Pai 2024-06-27 04:38:32 +00:00
parent 6682305ee2
commit 9bb675f89d
7 changed files with 705 additions and 0 deletions

View file

@ -201,6 +201,9 @@ class SinkChannelImpl
@Override
public void kill() {
// wait for any write operation to complete before trying to close
writeLock.lock();
writeLock.unlock();
synchronized (stateLock) {
if (state == ST_CLOSING) {
tryFinishClose();

View file

@ -200,6 +200,9 @@ class SourceChannelImpl
}
@Override
public void kill() {
// wait for any read operation to complete before trying to close
readLock.lock();
readLock.unlock();
synchronized (stateLock) {
assert !isOpen();
if (state == ST_CLOSING) {