mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8317514: Ensure MemorySegment is initialized before touching NativeMemorySegmentImpl
Co-authored-by: Jorn Vernee <jvernee@openjdk.org> Reviewed-by: jvernee
This commit is contained in:
parent
9622de2aa8
commit
7cb2e6d65b
12 changed files with 338 additions and 183 deletions
|
@ -50,9 +50,8 @@ import java.util.Objects;
|
|||
|
||||
import jdk.internal.access.JavaIOFileDescriptorAccess;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import jdk.internal.foreign.AbstractMemorySegmentImpl;
|
||||
import jdk.internal.foreign.MappedMemorySegmentImpl;
|
||||
import jdk.internal.foreign.MemorySessionImpl;
|
||||
import jdk.internal.foreign.SegmentFactories;
|
||||
import jdk.internal.misc.Blocker;
|
||||
import jdk.internal.misc.ExtendedMapMode;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
@ -1335,22 +1334,7 @@ public class FileChannelImpl
|
|||
if (mode == MapMode.READ_ONLY) {
|
||||
readOnly = true;
|
||||
}
|
||||
if (unmapper != null) {
|
||||
AbstractMemorySegmentImpl segment =
|
||||
new MappedMemorySegmentImpl(unmapper.address(), unmapper, size,
|
||||
readOnly, sessionImpl);
|
||||
MemorySessionImpl.ResourceList.ResourceCleanup resource =
|
||||
new MemorySessionImpl.ResourceList.ResourceCleanup() {
|
||||
@Override
|
||||
public void cleanup() {
|
||||
unmapper.unmap();
|
||||
}
|
||||
};
|
||||
sessionImpl.addOrCleanupIfFail(resource);
|
||||
return segment;
|
||||
} else {
|
||||
return new MappedMemorySegmentImpl(0, null, 0, readOnly, sessionImpl);
|
||||
}
|
||||
return SegmentFactories.mapSegment(size, unmapper, readOnly, sessionImpl);
|
||||
}
|
||||
|
||||
private Unmapper mapInternal(MapMode mode, long position, long size, int prot, boolean isSync)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue