8140241: (fc) Data transfer from FileChannel to itself causes hang in case of overlap

Reviewed-by: alanb
This commit is contained in:
Brian Burkhalter 2021-08-12 15:27:09 +00:00
parent 93cab7d07d
commit 428d51694f
6 changed files with 167 additions and 7 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -126,6 +126,10 @@ class FileDispatcherImpl extends FileDispatcher {
return false;
}
boolean canTransferToFromOverlappedMap() {
return canTransferToFromOverlappedMap0();
}
int setDirectIO(FileDescriptor fd, String path) {
int result = -1;
try {
@ -184,6 +188,8 @@ class FileDispatcherImpl extends FileDispatcher {
static native void closeIntFD(int fd) throws IOException;
static native boolean canTransferToFromOverlappedMap0();
static native int setDirect0(FileDescriptor fd) throws IOException;
static native void init();

View file

@ -338,6 +338,16 @@ Java_sun_nio_ch_FileDispatcherImpl_closeIntFD(JNIEnv *env, jclass clazz, jint fd
closeFileDescriptor(env, fd);
}
JNIEXPORT jboolean JNICALL
Java_sun_nio_ch_FileDispatcherImpl_canTransferToFromOverlappedMap0(JNIEnv *env, jclass clazz)
{
#ifdef MACOSX
return JNI_FALSE;
#else
return JNI_TRUE;
#endif
}
JNIEXPORT jint JNICALL
Java_sun_nio_ch_FileDispatcherImpl_setDirect0(JNIEnv *env, jclass clazz,
jobject fdo)