mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8064407: (fc) FileChannel transferTo should use TransmitFile on Windows
Co-authored-by: Valeriy Kopylov <v-valkop@microsoft.com> Reviewed-by: alanb
This commit is contained in:
parent
c278cc80e9
commit
9eafb6c406
7 changed files with 160 additions and 41 deletions
|
@ -25,21 +25,21 @@
|
|||
|
||||
package sun.nio.ch;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.security.PrivilegedAction;
|
||||
import sun.misc.SharedSecrets;
|
||||
import sun.misc.JavaIOFileDescriptorAccess;
|
||||
|
||||
class FileDispatcherImpl extends FileDispatcher
|
||||
{
|
||||
class FileDispatcherImpl extends FileDispatcher {
|
||||
|
||||
private static final JavaIOFileDescriptorAccess fdAccess =
|
||||
SharedSecrets.getJavaIOFileDescriptorAccess();
|
||||
|
||||
static {
|
||||
IOUtil.load();
|
||||
}
|
||||
// set to true if fast file transmission (TransmitFile) is enabled
|
||||
private static final boolean fastFileTransfer;
|
||||
|
||||
FileDispatcherImpl() {
|
||||
}
|
||||
FileDispatcherImpl() { }
|
||||
|
||||
@Override
|
||||
boolean needsPositionLock() {
|
||||
|
@ -110,6 +110,36 @@ class FileDispatcherImpl extends FileDispatcher
|
|||
return result;
|
||||
}
|
||||
|
||||
boolean canTransferToDirectly(java.nio.channels.SelectableChannel sc) {
|
||||
return fastFileTransfer && sc.isBlocking();
|
||||
}
|
||||
|
||||
boolean transferToDirectlyNeedsPositionLock() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean isFastFileTransferRequested() {
|
||||
String fileTransferProp = java.security.AccessController.doPrivileged(
|
||||
new PrivilegedAction<String>() {
|
||||
@Override
|
||||
public String run() {
|
||||
return System.getProperty("jdk.net.enableFastFileTransfer");
|
||||
}
|
||||
});
|
||||
boolean enable;
|
||||
if ("".equals(fileTransferProp)) {
|
||||
enable = true;
|
||||
} else {
|
||||
enable = Boolean.parseBoolean(fileTransferProp);
|
||||
}
|
||||
return enable;
|
||||
}
|
||||
|
||||
static {
|
||||
IOUtil.load();
|
||||
fastFileTransfer = isFastFileTransferRequested();
|
||||
}
|
||||
|
||||
//-- Native methods
|
||||
|
||||
static native int read0(FileDescriptor fd, long address, int len)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue