mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8316337: (bf) Concurrency issue in DirectByteBuffer.Deallocator
Reviewed-by: alanb, liach
This commit is contained in:
parent
4461eeb31d
commit
cf74b8c2a3
3 changed files with 31 additions and 45 deletions
|
@ -1154,10 +1154,10 @@ public class FileChannelImpl
|
|||
|
||||
// -- Memory-mapped buffers --
|
||||
|
||||
private abstract static class Unmapper
|
||||
private sealed abstract static class Unmapper
|
||||
implements Runnable, UnmapperProxy
|
||||
{
|
||||
private volatile long address;
|
||||
private final long address;
|
||||
protected final long size;
|
||||
protected final long cap;
|
||||
private final FileDescriptor fd;
|
||||
|
@ -1194,10 +1194,7 @@ public class FileChannelImpl
|
|||
}
|
||||
|
||||
public void unmap() {
|
||||
if (address == 0)
|
||||
return;
|
||||
nd.unmap(address, size);
|
||||
address = 0;
|
||||
|
||||
// if this mapping has a valid file descriptor then we close it
|
||||
if (fd.valid()) {
|
||||
|
@ -1214,7 +1211,7 @@ public class FileChannelImpl
|
|||
protected abstract void decrementStats();
|
||||
}
|
||||
|
||||
private static class DefaultUnmapper extends Unmapper {
|
||||
private static final class DefaultUnmapper extends Unmapper {
|
||||
|
||||
// keep track of non-sync mapped buffer usage
|
||||
static volatile int count;
|
||||
|
@ -1247,7 +1244,7 @@ public class FileChannelImpl
|
|||
}
|
||||
}
|
||||
|
||||
private static class SyncUnmapper extends Unmapper {
|
||||
private static final class SyncUnmapper extends Unmapper {
|
||||
|
||||
// keep track of mapped buffer usage
|
||||
static volatile int count;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue