8312127: FileDescriptor.sync should temporarily increase parallelism
Reviewed-by: shade, bpb
This commit is contained in:
parent
201e3bcf52
commit
fbe51e388d
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -31,6 +31,7 @@ import java.util.Objects;
|
|||||||
|
|
||||||
import jdk.internal.access.JavaIOFileDescriptorAccess;
|
import jdk.internal.access.JavaIOFileDescriptorAccess;
|
||||||
import jdk.internal.access.SharedSecrets;
|
import jdk.internal.access.SharedSecrets;
|
||||||
|
import jdk.internal.misc.Blocker;
|
||||||
import jdk.internal.ref.PhantomCleanable;
|
import jdk.internal.ref.PhantomCleanable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -205,7 +206,17 @@ public final class FileDescriptor {
|
|||||||
* buffers have been synchronized with physical media.
|
* buffers have been synchronized with physical media.
|
||||||
* @since 1.1
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public native void sync() throws SyncFailedException;
|
public void sync() throws SyncFailedException {
|
||||||
|
long comp = Blocker.begin();
|
||||||
|
try {
|
||||||
|
sync0();
|
||||||
|
} finally {
|
||||||
|
Blocker.end(comp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* fsync/equivalent this file descriptor */
|
||||||
|
private native void sync0() throws SyncFailedException;
|
||||||
|
|
||||||
/* This routine initializes JNI field offsets for the class */
|
/* This routine initializes JNI field offsets for the class */
|
||||||
private static native void initIDs();
|
private static native void initIDs();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -58,7 +58,7 @@ Java_java_io_FileDescriptor_initIDs(JNIEnv *env, jclass fdClass) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_java_io_FileDescriptor_sync(JNIEnv *env, jobject this) {
|
Java_java_io_FileDescriptor_sync0(JNIEnv *env, jobject this) {
|
||||||
FD fd = THIS_FD(this);
|
FD fd = THIS_FD(this);
|
||||||
if (IO_Sync(fd) == -1) {
|
if (IO_Sync(fd) == -1) {
|
||||||
JNU_ThrowByName(env, "java/io/SyncFailedException", "sync failed");
|
JNU_ThrowByName(env, "java/io/SyncFailedException", "sync failed");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -61,7 +61,7 @@ Java_java_io_FileDescriptor_initIDs(JNIEnv *env, jclass fdClass) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_java_io_FileDescriptor_sync(JNIEnv *env, jobject this) {
|
Java_java_io_FileDescriptor_sync0(JNIEnv *env, jobject this) {
|
||||||
FD fd = THIS_FD(this);
|
FD fd = THIS_FD(this);
|
||||||
if (IO_Sync(fd) == -1) {
|
if (IO_Sync(fd) == -1) {
|
||||||
JNU_ThrowByName(env, "java/io/SyncFailedException", "sync failed");
|
JNU_ThrowByName(env, "java/io/SyncFailedException", "sync failed");
|
||||||
|
Loading…
Reference in New Issue
Block a user