mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
Merge
This commit is contained in:
commit
dfe0ca547b
1443 changed files with 96807 additions and 67965 deletions
|
@ -1666,25 +1666,33 @@ public final class StringConcatFactory {
|
|||
// and deduce the coder from there. Arguments would be either converted to Strings
|
||||
// during the initial filtering, or handled by specializations in MIXERS.
|
||||
//
|
||||
// The method handle shape before and after all mixers are combined in is:
|
||||
// The method handle shape before all mixers are combined in is:
|
||||
// (long, <args>)String = ("indexCoder", <args>)
|
||||
//
|
||||
// We will bind the initialLengthCoder value to the last mixer (the one that will be
|
||||
// executed first), then fold that in. This leaves the shape after all mixers are
|
||||
// combined in as:
|
||||
// (<args>)String = (<args>)
|
||||
|
||||
int ac = -1;
|
||||
MethodHandle mix = null;
|
||||
for (RecipeElement el : recipe.getElements()) {
|
||||
switch (el.getTag()) {
|
||||
case TAG_CONST:
|
||||
// Constants already handled in the code above
|
||||
break;
|
||||
case TAG_ARG:
|
||||
int ac = el.getArgPos();
|
||||
if (ac >= 0) {
|
||||
// Compute new "index" in-place using old value plus the appropriate argument.
|
||||
mh = MethodHandles.filterArgumentsWithCombiner(mh, 0, mix,
|
||||
0, // old-index
|
||||
1 + ac // selected argument
|
||||
);
|
||||
}
|
||||
|
||||
ac = el.getArgPos();
|
||||
Class<?> argClass = ptypes[ac];
|
||||
MethodHandle mix = mixer(argClass);
|
||||
|
||||
// Compute new "index" in-place using old value plus the appropriate argument.
|
||||
mh = MethodHandles.filterArgumentsWithCombiner(mh, 0, mix,
|
||||
0, // old-index
|
||||
1 + ac // selected argument
|
||||
);
|
||||
mix = mixer(argClass);
|
||||
|
||||
break;
|
||||
default:
|
||||
|
@ -1692,9 +1700,19 @@ public final class StringConcatFactory {
|
|||
}
|
||||
}
|
||||
|
||||
// Insert initial length and coder value here.
|
||||
// Insert the initialLengthCoder value into the final mixer, then
|
||||
// fold that into the base method handle
|
||||
if (ac >= 0) {
|
||||
mix = MethodHandles.insertArguments(mix, 0, initialLengthCoder);
|
||||
mh = MethodHandles.foldArgumentsWithCombiner(mh, 0, mix,
|
||||
1 + ac // selected argument
|
||||
);
|
||||
} else {
|
||||
// No mixer (constants only concat), insert initialLengthCoder directly
|
||||
mh = MethodHandles.insertArguments(mh, 0, initialLengthCoder);
|
||||
}
|
||||
|
||||
// The method handle shape here is (<args>).
|
||||
mh = MethodHandles.insertArguments(mh, 0, initialLengthCoder);
|
||||
|
||||
// Apply filters, converting the arguments:
|
||||
if (filters != null) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2019, 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
|
||||
|
@ -27,6 +27,7 @@ package java.nio;
|
|||
|
||||
import java.io.FileDescriptor;
|
||||
import java.lang.ref.Reference;
|
||||
import java.util.Objects;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
|
||||
|
@ -91,20 +92,52 @@ public abstract class MappedByteBuffer
|
|||
this.fd = null;
|
||||
}
|
||||
|
||||
// Returns the distance (in bytes) of the buffer from the page aligned address
|
||||
// of the mapping. Computed each time to avoid storing in every direct buffer.
|
||||
// Returns the distance (in bytes) of the buffer start from the
|
||||
// largest page aligned address of the mapping less than or equal
|
||||
// to the start address.
|
||||
private long mappingOffset() {
|
||||
return mappingOffset(0);
|
||||
}
|
||||
|
||||
// Returns the distance (in bytes) of the buffer element
|
||||
// identified by index from the largest page aligned address of
|
||||
// the mapping less than or equal to the element address. Computed
|
||||
// each time to avoid storing in every direct buffer.
|
||||
private long mappingOffset(int index) {
|
||||
int ps = Bits.pageSize();
|
||||
long offset = address % ps;
|
||||
return (offset >= 0) ? offset : (ps + offset);
|
||||
long indexAddress = address + index;
|
||||
long baseAddress = (indexAddress & ~(ps-1));
|
||||
return indexAddress - baseAddress;
|
||||
}
|
||||
|
||||
// Given an offset previously obtained from calling
|
||||
// mappingOffset() returns the largest page aligned address of the
|
||||
// mapping less than or equal to the buffer start address.
|
||||
private long mappingAddress(long mappingOffset) {
|
||||
return address - mappingOffset;
|
||||
return mappingAddress(mappingOffset, 0);
|
||||
}
|
||||
|
||||
// Given an offset previously otained from calling
|
||||
// mappingOffset(index) returns the largest page aligned address
|
||||
// of the mapping less than or equal to the address of the buffer
|
||||
// element identified by index.
|
||||
private long mappingAddress(long mappingOffset, long index) {
|
||||
long indexAddress = address + index;
|
||||
return indexAddress - mappingOffset;
|
||||
}
|
||||
|
||||
// given a mappingOffset previously otained from calling
|
||||
// mappingOffset() return that offset added to the buffer
|
||||
// capacity.
|
||||
private long mappingLength(long mappingOffset) {
|
||||
return (long)capacity() + mappingOffset;
|
||||
return mappingLength(mappingOffset, (long)capacity());
|
||||
}
|
||||
|
||||
// given a mappingOffset previously otained from calling
|
||||
// mappingOffset(index) return that offset added to the supplied
|
||||
// length.
|
||||
private long mappingLength(long mappingOffset, long length) {
|
||||
return length + mappingOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,6 +245,58 @@ public abstract class MappedByteBuffer
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces any changes made to a region of this buffer's content to
|
||||
* be written to the storage device containing the mapped
|
||||
* file. The region starts at the given {@code index} in this
|
||||
* buffer and is {@code length} bytes.
|
||||
*
|
||||
* <p> If the file mapped into this buffer resides on a local
|
||||
* storage device then when this method returns it is guaranteed
|
||||
* that all changes made to the selected region buffer since it
|
||||
* was created, or since this method was last invoked, will have
|
||||
* been written to that device. The force operation is free to
|
||||
* write bytes that lie outside the specified region, for example
|
||||
* to ensure that data blocks of some device-specific granularity
|
||||
* are transferred in their entirety.
|
||||
*
|
||||
* <p> If the file does not reside on a local device then no such
|
||||
* guarantee is made.
|
||||
*
|
||||
* <p> If this buffer was not mapped in read/write mode ({@link
|
||||
* java.nio.channels.FileChannel.MapMode#READ_WRITE}) then
|
||||
* invoking this method has no effect. </p>
|
||||
*
|
||||
* @param index
|
||||
* The index of the first byte in the buffer region that is
|
||||
* to be written back to storage; must be non-negative
|
||||
* and less than limit()
|
||||
*
|
||||
* @param length
|
||||
* The length of the region in bytes; must be non-negative
|
||||
* and no larger than limit() - index
|
||||
*
|
||||
* @throws IndexOutOfBoundsException
|
||||
* if the preconditions on the index and length do not
|
||||
* hold.
|
||||
*
|
||||
* @return This buffer
|
||||
*
|
||||
* @since 13
|
||||
*/
|
||||
public final MappedByteBuffer force(int index, int length) {
|
||||
if (fd == null) {
|
||||
return this;
|
||||
}
|
||||
if ((address != 0) && (limit() != 0)) {
|
||||
// check inputs
|
||||
Objects.checkFromIndexSize(index, length, limit());
|
||||
long offset = mappingOffset(index);
|
||||
force0(fd, mappingAddress(offset, index), mappingLength(offset, length));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private native boolean isLoaded0(long address, long length, int pageCount);
|
||||
private native void load0(long address, long length);
|
||||
private native void force0(FileDescriptor fd, long address, long length);
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.nio.channels.AsynchronousCloseException;
|
|||
import java.nio.channels.Channel;
|
||||
import java.nio.channels.ClosedByInterruptException;
|
||||
import java.nio.channels.InterruptibleChannel;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import sun.nio.ch.Interruptible;
|
||||
|
@ -86,7 +85,7 @@ import sun.nio.ch.Interruptible;
|
|||
public abstract class AbstractInterruptibleChannel
|
||||
implements Channel, InterruptibleChannel
|
||||
{
|
||||
private final ReentrantLock closeLock = new ReentrantLock();
|
||||
private final Object closeLock = new Object();
|
||||
private volatile boolean closed;
|
||||
|
||||
/**
|
||||
|
@ -106,14 +105,11 @@ public abstract class AbstractInterruptibleChannel
|
|||
* If an I/O error occurs
|
||||
*/
|
||||
public final void close() throws IOException {
|
||||
closeLock.lock();
|
||||
try {
|
||||
synchronized (closeLock) {
|
||||
if (closed)
|
||||
return;
|
||||
closed = true;
|
||||
implCloseChannel();
|
||||
} finally {
|
||||
closeLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,8 +153,7 @@ public abstract class AbstractInterruptibleChannel
|
|||
if (interruptor == null) {
|
||||
interruptor = new Interruptible() {
|
||||
public void interrupt(Thread target) {
|
||||
closeLock.lock();
|
||||
try {
|
||||
synchronized (closeLock) {
|
||||
if (closed)
|
||||
return;
|
||||
closed = true;
|
||||
|
@ -166,8 +161,6 @@ public abstract class AbstractInterruptibleChannel
|
|||
try {
|
||||
AbstractInterruptibleChannel.this.implCloseChannel();
|
||||
} catch (IOException x) { }
|
||||
} finally {
|
||||
closeLock.unlock();
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2019, 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
|
||||
|
@ -113,9 +113,11 @@ public abstract class Resource {
|
|||
int bytesToRead;
|
||||
if (pos >= b.length) { // Only expand when there's no room
|
||||
bytesToRead = Math.min(len - pos, b.length + 1024);
|
||||
if (b.length < pos + bytesToRead) {
|
||||
b = Arrays.copyOf(b, pos + bytesToRead);
|
||||
if (bytesToRead < 0) {
|
||||
// Can overflow only due to large b.length
|
||||
bytesToRead = len - pos;
|
||||
}
|
||||
b = Arrays.copyOf(b, pos + bytesToRead);
|
||||
} else {
|
||||
bytesToRead = b.length - pos;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,6 @@ import java.util.Collections;
|
|||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import sun.net.ResourceManager;
|
||||
|
@ -90,8 +89,7 @@ class DatagramChannelImpl
|
|||
|
||||
// Lock held by any thread that modifies the state fields declared below
|
||||
// DO NOT invoke a blocking I/O operation while holding this lock!
|
||||
private final ReentrantLock stateLock = new ReentrantLock();
|
||||
private final Condition stateCondition = stateLock.newCondition();
|
||||
private final Object stateLock = new Object();
|
||||
|
||||
// -- The following fields are protected by stateLock
|
||||
|
||||
|
@ -99,8 +97,7 @@ class DatagramChannelImpl
|
|||
private static final int ST_UNCONNECTED = 0;
|
||||
private static final int ST_CONNECTED = 1;
|
||||
private static final int ST_CLOSING = 2;
|
||||
private static final int ST_KILLPENDING = 3;
|
||||
private static final int ST_KILLED = 4;
|
||||
private static final int ST_CLOSED = 3;
|
||||
private int state;
|
||||
|
||||
// IDs of native threads doing reads and writes, for signalling
|
||||
|
@ -181,11 +178,8 @@ class DatagramChannelImpl
|
|||
: StandardProtocolFamily.INET;
|
||||
this.fd = fd;
|
||||
this.fdVal = IOUtil.fdVal(fd);
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
this.localAddress = Net.localAddress(fd);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,36 +191,27 @@ class DatagramChannelImpl
|
|||
|
||||
@Override
|
||||
public DatagramSocket socket() {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
if (socket == null)
|
||||
socket = DatagramSocketAdaptor.create(this);
|
||||
return socket;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getLocalAddress() throws IOException {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
// Perform security check before returning address
|
||||
return Net.getRevealedLocalAddress(localAddress);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getRemoteAddress() throws IOException {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
return remoteAddress;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,8 +223,7 @@ class DatagramChannelImpl
|
|||
if (!supportedOptions().contains(name))
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
|
||||
if (name == StandardSocketOptions.IP_TOS ||
|
||||
|
@ -279,8 +263,6 @@ class DatagramChannelImpl
|
|||
// remaining options don't need any special handling
|
||||
Net.setSocketOption(fd, Net.UNSPEC, name, value);
|
||||
return this;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,8 +275,7 @@ class DatagramChannelImpl
|
|||
if (!supportedOptions().contains(name))
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
|
||||
if (name == StandardSocketOptions.IP_TOS ||
|
||||
|
@ -333,8 +314,6 @@ class DatagramChannelImpl
|
|||
|
||||
// no special handling
|
||||
return (T) Net.getSocketOption(fd, Net.UNSPEC, name);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,8 +361,7 @@ class DatagramChannelImpl
|
|||
begin();
|
||||
}
|
||||
SocketAddress remote;
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
remote = remoteAddress;
|
||||
if ((remote == null) && mustBeConnected)
|
||||
|
@ -392,8 +370,6 @@ class DatagramChannelImpl
|
|||
bindInternal(null);
|
||||
if (blocking)
|
||||
readerThread = NativeThread.current();
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
return remote;
|
||||
}
|
||||
|
@ -407,15 +383,11 @@ class DatagramChannelImpl
|
|||
throws AsynchronousCloseException
|
||||
{
|
||||
if (blocking) {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
readerThread = 0;
|
||||
// notify any thread waiting in implCloseSelectableChannel
|
||||
if (state == ST_CLOSING) {
|
||||
stateCondition.signalAll();
|
||||
tryFinishClose();
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
// remove hook for Thread.interrupt
|
||||
end(completed);
|
||||
|
@ -708,8 +680,7 @@ class DatagramChannelImpl
|
|||
begin();
|
||||
}
|
||||
SocketAddress remote;
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
remote = remoteAddress;
|
||||
if ((remote == null) && mustBeConnected)
|
||||
|
@ -718,8 +689,6 @@ class DatagramChannelImpl
|
|||
bindInternal(null);
|
||||
if (blocking)
|
||||
writerThread = NativeThread.current();
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
return remote;
|
||||
}
|
||||
|
@ -733,15 +702,11 @@ class DatagramChannelImpl
|
|||
throws AsynchronousCloseException
|
||||
{
|
||||
if (blocking) {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
writerThread = 0;
|
||||
// notify any thread waiting in implCloseSelectableChannel
|
||||
if (state == ST_CLOSING) {
|
||||
stateCondition.signalAll();
|
||||
tryFinishClose();
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
// remove hook for Thread.interrupt
|
||||
end(completed);
|
||||
|
@ -810,12 +775,9 @@ class DatagramChannelImpl
|
|||
try {
|
||||
writeLock.lock();
|
||||
try {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
IOUtil.configureBlocking(fd, block);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
} finally {
|
||||
writeLock.unlock();
|
||||
|
@ -826,20 +788,14 @@ class DatagramChannelImpl
|
|||
}
|
||||
|
||||
InetSocketAddress localAddress() {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
return localAddress;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
InetSocketAddress remoteAddress() {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
return remoteAddress;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -849,14 +805,11 @@ class DatagramChannelImpl
|
|||
try {
|
||||
writeLock.lock();
|
||||
try {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
if (localAddress != null)
|
||||
throw new AlreadyBoundException();
|
||||
bindInternal(local);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
} finally {
|
||||
writeLock.unlock();
|
||||
|
@ -868,7 +821,7 @@ class DatagramChannelImpl
|
|||
}
|
||||
|
||||
private void bindInternal(SocketAddress local) throws IOException {
|
||||
assert stateLock.isHeldByCurrentThread() && (localAddress == null);
|
||||
assert Thread.holdsLock(stateLock )&& (localAddress == null);
|
||||
|
||||
InetSocketAddress isa;
|
||||
if (local == null) {
|
||||
|
@ -891,11 +844,8 @@ class DatagramChannelImpl
|
|||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
return (state == ST_CONNECTED);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -917,8 +867,7 @@ class DatagramChannelImpl
|
|||
try {
|
||||
writeLock.lock();
|
||||
try {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
if (state == ST_CONNECTED)
|
||||
throw new AlreadyConnectedException();
|
||||
|
@ -952,9 +901,6 @@ class DatagramChannelImpl
|
|||
IOUtil.configureBlocking(fd, true);
|
||||
}
|
||||
}
|
||||
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
} finally {
|
||||
writeLock.unlock();
|
||||
|
@ -971,8 +917,7 @@ class DatagramChannelImpl
|
|||
try {
|
||||
writeLock.lock();
|
||||
try {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
if (!isOpen() || (state != ST_CONNECTED))
|
||||
return this;
|
||||
|
||||
|
@ -986,8 +931,6 @@ class DatagramChannelImpl
|
|||
|
||||
// refresh local address
|
||||
localAddress = Net.localAddress(fd);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
} finally {
|
||||
writeLock.unlock();
|
||||
|
@ -1035,8 +978,7 @@ class DatagramChannelImpl
|
|||
if (sm != null)
|
||||
sm.checkMulticast(group);
|
||||
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
|
||||
// check the registry to see if we are already a member of the group
|
||||
|
@ -1091,8 +1033,6 @@ class DatagramChannelImpl
|
|||
|
||||
registry.add(key);
|
||||
return key;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1118,8 +1058,7 @@ class DatagramChannelImpl
|
|||
void drop(MembershipKeyImpl key) {
|
||||
assert key.channel() == this;
|
||||
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
if (!key.isValid())
|
||||
return;
|
||||
|
||||
|
@ -1140,8 +1079,6 @@ class DatagramChannelImpl
|
|||
|
||||
key.invalidate();
|
||||
registry.remove(key);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1155,8 +1092,7 @@ class DatagramChannelImpl
|
|||
assert key.channel() == this;
|
||||
assert key.sourceAddress() == null;
|
||||
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
if (!key.isValid())
|
||||
throw new IllegalStateException("key is no longer valid");
|
||||
if (source.isAnyLocalAddress())
|
||||
|
@ -1182,8 +1118,6 @@ class DatagramChannelImpl
|
|||
// ancient kernel
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1194,8 +1128,7 @@ class DatagramChannelImpl
|
|||
assert key.channel() == this;
|
||||
assert key.sourceAddress() == null;
|
||||
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
if (!key.isValid())
|
||||
throw new IllegalStateException("key is no longer valid");
|
||||
|
||||
|
@ -1215,116 +1148,117 @@ class DatagramChannelImpl
|
|||
// should not happen
|
||||
throw new AssertionError(ioe);
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked by implCloseChannel to close the channel.
|
||||
*
|
||||
* This method waits for outstanding I/O operations to complete. When in
|
||||
* blocking mode, the socket is pre-closed and the threads in blocking I/O
|
||||
* operations are signalled to ensure that the outstanding I/O operations
|
||||
* complete quickly.
|
||||
*
|
||||
* The socket is closed by this method when it is not registered with a
|
||||
* Selector. Note that a channel configured blocking may be registered with
|
||||
* a Selector. This arises when a key is canceled and the channel configured
|
||||
* to blocking mode before the key is flushed from the Selector.
|
||||
* Closes the socket if there are no I/O operations in progress and the
|
||||
* channel is not registered with a Selector.
|
||||
*/
|
||||
@Override
|
||||
protected void implCloseSelectableChannel() throws IOException {
|
||||
assert !isOpen();
|
||||
private boolean tryClose() throws IOException {
|
||||
assert Thread.holdsLock(stateLock) && state == ST_CLOSING;
|
||||
if ((readerThread == 0) && (writerThread == 0) && !isRegistered()) {
|
||||
state = ST_CLOSED;
|
||||
try {
|
||||
nd.close(fd);
|
||||
} finally {
|
||||
// notify resource manager
|
||||
ResourceManager.afterUdpClose();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
boolean blocking;
|
||||
boolean interrupted = false;
|
||||
|
||||
// set state to ST_CLOSING and invalid membership keys
|
||||
stateLock.lock();
|
||||
/**
|
||||
* Invokes tryClose to attempt to close the socket.
|
||||
*
|
||||
* This method is used for deferred closing by I/O and Selector operations.
|
||||
*/
|
||||
private void tryFinishClose() {
|
||||
try {
|
||||
tryClose();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes this channel when configured in blocking mode.
|
||||
*
|
||||
* If there is an I/O operation in progress then the socket is pre-closed
|
||||
* and the I/O threads signalled, in which case the final close is deferred
|
||||
* until all I/O operations complete.
|
||||
*/
|
||||
private void implCloseBlockingMode() throws IOException {
|
||||
synchronized (stateLock) {
|
||||
assert state < ST_CLOSING;
|
||||
blocking = isBlocking();
|
||||
state = ST_CLOSING;
|
||||
|
||||
// if member of any multicast groups then invalidate the keys
|
||||
if (registry != null)
|
||||
registry.invalidateAll();
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
|
||||
// wait for any outstanding I/O operations to complete
|
||||
if (blocking) {
|
||||
stateLock.lock();
|
||||
try {
|
||||
assert state == ST_CLOSING;
|
||||
if (!tryClose()) {
|
||||
long reader = readerThread;
|
||||
long writer = writerThread;
|
||||
if (reader != 0 || writer != 0) {
|
||||
nd.preClose(fd);
|
||||
|
||||
if (reader != 0)
|
||||
NativeThread.signal(reader);
|
||||
if (writer != 0)
|
||||
NativeThread.signal(writer);
|
||||
|
||||
// wait for blocking I/O operations to end
|
||||
while (readerThread != 0 || writerThread != 0) {
|
||||
try {
|
||||
stateCondition.await();
|
||||
} catch (InterruptedException e) {
|
||||
interrupted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes this channel when configured in non-blocking mode.
|
||||
*
|
||||
* If the channel is registered with a Selector then the close is deferred
|
||||
* until the channel is flushed from all Selectors.
|
||||
*/
|
||||
private void implCloseNonBlockingMode() throws IOException {
|
||||
synchronized (stateLock) {
|
||||
assert state < ST_CLOSING;
|
||||
state = ST_CLOSING;
|
||||
|
||||
// if member of any multicast groups then invalidate the keys
|
||||
if (registry != null)
|
||||
registry.invalidateAll();
|
||||
}
|
||||
|
||||
// wait for any read/write operations to complete before trying to close
|
||||
readLock.lock();
|
||||
readLock.unlock();
|
||||
writeLock.lock();
|
||||
writeLock.unlock();
|
||||
synchronized (stateLock) {
|
||||
if (state == ST_CLOSING) {
|
||||
tryClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked by implCloseChannel to close the channel.
|
||||
*/
|
||||
@Override
|
||||
protected void implCloseSelectableChannel() throws IOException {
|
||||
assert !isOpen();
|
||||
if (isBlocking()) {
|
||||
implCloseBlockingMode();
|
||||
} else {
|
||||
// non-blocking mode: wait for read/write to complete
|
||||
readLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
writeLock.unlock();
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
implCloseNonBlockingMode();
|
||||
}
|
||||
|
||||
// set state to ST_KILLPENDING
|
||||
stateLock.lock();
|
||||
try {
|
||||
assert state == ST_CLOSING;
|
||||
state = ST_KILLPENDING;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
|
||||
// close socket if not registered with Selector
|
||||
if (!isRegistered())
|
||||
kill();
|
||||
|
||||
// restore interrupt status
|
||||
if (interrupted)
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kill() throws IOException {
|
||||
stateLock.lock();
|
||||
try {
|
||||
if (state == ST_KILLPENDING) {
|
||||
state = ST_KILLED;
|
||||
try {
|
||||
nd.close(fd);
|
||||
} finally {
|
||||
// notify resource manager
|
||||
ResourceManager.afterUdpClose();
|
||||
}
|
||||
public void kill() {
|
||||
synchronized (stateLock) {
|
||||
if (state == ST_CLOSING) {
|
||||
tryFinishClose();
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ import java.util.Collections;
|
|||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import sun.net.NetHooks;
|
||||
|
@ -72,16 +71,14 @@ class ServerSocketChannelImpl
|
|||
|
||||
// Lock held by any thread that modifies the state fields declared below
|
||||
// DO NOT invoke a blocking I/O operation while holding this lock!
|
||||
private final ReentrantLock stateLock = new ReentrantLock();
|
||||
private final Condition stateCondition = stateLock.newCondition();
|
||||
private final Object stateLock = new Object();
|
||||
|
||||
// -- The following fields are protected by stateLock
|
||||
|
||||
// Channel state, increases monotonically
|
||||
private static final int ST_INUSE = 0;
|
||||
private static final int ST_CLOSING = 1;
|
||||
private static final int ST_KILLPENDING = 2;
|
||||
private static final int ST_KILLED = 3;
|
||||
private static final int ST_CLOSED = 2;
|
||||
private int state;
|
||||
|
||||
// ID of native thread currently blocked in this channel, for signalling
|
||||
|
@ -112,11 +109,8 @@ class ServerSocketChannelImpl
|
|||
this.fd = fd;
|
||||
this.fdVal = IOUtil.fdVal(fd);
|
||||
if (bound) {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
localAddress = Net.localAddress(fd);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,26 +123,20 @@ class ServerSocketChannelImpl
|
|||
|
||||
@Override
|
||||
public ServerSocket socket() {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
if (socket == null)
|
||||
socket = ServerSocketAdaptor.create(this);
|
||||
return socket;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getLocalAddress() throws IOException {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
return (localAddress == null)
|
||||
? null
|
||||
: Net.getRevealedLocalAddress(localAddress);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,8 +147,7 @@ class ServerSocketChannelImpl
|
|||
Objects.requireNonNull(name);
|
||||
if (!supportedOptions().contains(name))
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
|
||||
if (name == StandardSocketOptions.SO_REUSEADDR && Net.useExclusiveBind()) {
|
||||
|
@ -171,8 +158,6 @@ class ServerSocketChannelImpl
|
|||
Net.setSocketOption(fd, Net.UNSPEC, name, value);
|
||||
}
|
||||
return this;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,8 +170,7 @@ class ServerSocketChannelImpl
|
|||
if (!supportedOptions().contains(name))
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
if (name == StandardSocketOptions.SO_REUSEADDR && Net.useExclusiveBind()) {
|
||||
// SO_REUSEADDR emulated when using exclusive bind
|
||||
|
@ -194,8 +178,6 @@ class ServerSocketChannelImpl
|
|||
}
|
||||
// no options that require special handling
|
||||
return (T) Net.getSocketOption(fd, Net.UNSPEC, name);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,8 +203,7 @@ class ServerSocketChannelImpl
|
|||
|
||||
@Override
|
||||
public ServerSocketChannel bind(SocketAddress local, int backlog) throws IOException {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
if (localAddress != null)
|
||||
throw new AlreadyBoundException();
|
||||
|
@ -236,8 +217,6 @@ class ServerSocketChannelImpl
|
|||
Net.bind(fd, isa.getAddress(), isa.getPort());
|
||||
Net.listen(fd, backlog < 1 ? 50 : backlog);
|
||||
localAddress = Net.localAddress(fd);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -251,15 +230,12 @@ class ServerSocketChannelImpl
|
|||
private void begin(boolean blocking) throws ClosedChannelException {
|
||||
if (blocking)
|
||||
begin(); // set blocker to close channel if interrupted
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
if (localAddress == null)
|
||||
throw new NotYetBoundException();
|
||||
if (blocking)
|
||||
thread = NativeThread.current();
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -273,15 +249,11 @@ class ServerSocketChannelImpl
|
|||
throws AsynchronousCloseException
|
||||
{
|
||||
if (blocking) {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
thread = 0;
|
||||
// notify any thread waiting in implCloseSelectableChannel
|
||||
if (state == ST_CLOSING) {
|
||||
stateCondition.signalAll();
|
||||
tryFinishClose();
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
end(completed);
|
||||
}
|
||||
|
@ -405,101 +377,99 @@ class ServerSocketChannelImpl
|
|||
*/
|
||||
private void lockedConfigureBlocking(boolean block) throws IOException {
|
||||
assert acceptLock.isHeldByCurrentThread();
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
IOUtil.configureBlocking(fd, block);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the socket if there are no accept in progress and the channel is
|
||||
* not registered with a Selector.
|
||||
*/
|
||||
private boolean tryClose() throws IOException {
|
||||
assert Thread.holdsLock(stateLock) && state == ST_CLOSING;
|
||||
if ((thread == 0) && !isRegistered()) {
|
||||
state = ST_CLOSED;
|
||||
nd.close(fd);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes tryClose to attempt to close the socket.
|
||||
*
|
||||
* This method is used for deferred closing by I/O and Selector operations.
|
||||
*/
|
||||
private void tryFinishClose() {
|
||||
try {
|
||||
tryClose();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes this channel when configured in blocking mode.
|
||||
*
|
||||
* If there is an accept in progress then the socket is pre-closed and the
|
||||
* accept thread is signalled, in which case the final close is deferred
|
||||
* until the accept aborts.
|
||||
*/
|
||||
private void implCloseBlockingMode() throws IOException {
|
||||
synchronized (stateLock) {
|
||||
assert state < ST_CLOSING;
|
||||
state = ST_CLOSING;
|
||||
if (!tryClose()) {
|
||||
long th = thread;
|
||||
if (th != 0) {
|
||||
nd.preClose(fd);
|
||||
NativeThread.signal(th);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes this channel when configured in non-blocking mode.
|
||||
*
|
||||
* If the channel is registered with a Selector then the close is deferred
|
||||
* until the channel is flushed from all Selectors.
|
||||
*/
|
||||
private void implCloseNonBlockingMode() throws IOException {
|
||||
synchronized (stateLock) {
|
||||
assert state < ST_CLOSING;
|
||||
state = ST_CLOSING;
|
||||
}
|
||||
// wait for any accept to complete before trying to close
|
||||
acceptLock.lock();
|
||||
acceptLock.unlock();
|
||||
synchronized (stateLock) {
|
||||
if (state == ST_CLOSING) {
|
||||
tryClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked by implCloseChannel to close the channel.
|
||||
*
|
||||
* This method waits for outstanding I/O operations to complete. When in
|
||||
* blocking mode, the socket is pre-closed and the threads in blocking I/O
|
||||
* operations are signalled to ensure that the outstanding I/O operations
|
||||
* complete quickly.
|
||||
*
|
||||
* The socket is closed by this method when it is not registered with a
|
||||
* Selector. Note that a channel configured blocking may be registered with
|
||||
* a Selector. This arises when a key is canceled and the channel configured
|
||||
* to blocking mode before the key is flushed from the Selector.
|
||||
*/
|
||||
@Override
|
||||
protected void implCloseSelectableChannel() throws IOException {
|
||||
assert !isOpen();
|
||||
|
||||
boolean interrupted = false;
|
||||
boolean blocking;
|
||||
|
||||
// set state to ST_CLOSING
|
||||
stateLock.lock();
|
||||
try {
|
||||
assert state < ST_CLOSING;
|
||||
state = ST_CLOSING;
|
||||
blocking = isBlocking();
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
|
||||
// wait for any outstanding accept to complete
|
||||
if (blocking) {
|
||||
stateLock.lock();
|
||||
try {
|
||||
assert state == ST_CLOSING;
|
||||
long th = thread;
|
||||
if (th != 0) {
|
||||
nd.preClose(fd);
|
||||
NativeThread.signal(th);
|
||||
|
||||
// wait for accept operation to end
|
||||
while (thread != 0) {
|
||||
try {
|
||||
stateCondition.await();
|
||||
} catch (InterruptedException e) {
|
||||
interrupted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
if (isBlocking()) {
|
||||
implCloseBlockingMode();
|
||||
} else {
|
||||
// non-blocking mode: wait for accept to complete
|
||||
acceptLock.lock();
|
||||
acceptLock.unlock();
|
||||
implCloseNonBlockingMode();
|
||||
}
|
||||
|
||||
// set state to ST_KILLPENDING
|
||||
stateLock.lock();
|
||||
try {
|
||||
assert state == ST_CLOSING;
|
||||
state = ST_KILLPENDING;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
|
||||
// close socket if not registered with Selector
|
||||
if (!isRegistered())
|
||||
kill();
|
||||
|
||||
// restore interrupt status
|
||||
if (interrupted)
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kill() throws IOException {
|
||||
stateLock.lock();
|
||||
try {
|
||||
if (state == ST_KILLPENDING) {
|
||||
state = ST_KILLED;
|
||||
nd.close(fd);
|
||||
public void kill() {
|
||||
synchronized (stateLock) {
|
||||
if (state == ST_CLOSING) {
|
||||
tryFinishClose();
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -507,11 +477,8 @@ class ServerSocketChannelImpl
|
|||
* Returns true if channel's socket is bound
|
||||
*/
|
||||
boolean isBound() {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
return localAddress != null;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -519,11 +486,8 @@ class ServerSocketChannelImpl
|
|||
* Returns the local address, or null if not bound
|
||||
*/
|
||||
InetSocketAddress localAddress() {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
return localAddress;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -589,16 +553,13 @@ class ServerSocketChannelImpl
|
|||
if (!isOpen()) {
|
||||
sb.append("closed");
|
||||
} else {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
InetSocketAddress addr = localAddress;
|
||||
if (addr == null) {
|
||||
sb.append("unbound");
|
||||
} else {
|
||||
sb.append(Net.getRevealedLocalAddressAsString(addr));
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
sb.append(']');
|
||||
|
|
|
@ -53,7 +53,6 @@ import java.util.Collections;
|
|||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import sun.net.ConnectionResetException;
|
||||
|
@ -84,8 +83,7 @@ class SocketChannelImpl
|
|||
|
||||
// Lock held by any thread that modifies the state fields declared below
|
||||
// DO NOT invoke a blocking I/O operation while holding this lock!
|
||||
private final ReentrantLock stateLock = new ReentrantLock();
|
||||
private final Condition stateCondition = stateLock.newCondition();
|
||||
private final Object stateLock = new Object();
|
||||
|
||||
// Input/Output closed
|
||||
private volatile boolean isInputClosed;
|
||||
|
@ -104,8 +102,7 @@ class SocketChannelImpl
|
|||
private static final int ST_CONNECTIONPENDING = 1;
|
||||
private static final int ST_CONNECTED = 2;
|
||||
private static final int ST_CLOSING = 3;
|
||||
private static final int ST_KILLPENDING = 4;
|
||||
private static final int ST_KILLED = 5;
|
||||
private static final int ST_CLOSED = 4;
|
||||
private volatile int state; // need stateLock to change
|
||||
|
||||
// IDs of native threads doing reads and writes, for signalling
|
||||
|
@ -137,11 +134,8 @@ class SocketChannelImpl
|
|||
this.fd = fd;
|
||||
this.fdVal = IOUtil.fdVal(fd);
|
||||
if (bound) {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
this.localAddress = Net.localAddress(fd);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,13 +148,10 @@ class SocketChannelImpl
|
|||
super(sp);
|
||||
this.fd = fd;
|
||||
this.fdVal = IOUtil.fdVal(fd);
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
this.localAddress = Net.localAddress(fd);
|
||||
this.remoteAddress = isa;
|
||||
this.state = ST_CONNECTED;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,35 +188,26 @@ class SocketChannelImpl
|
|||
|
||||
@Override
|
||||
public Socket socket() {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
if (socket == null)
|
||||
socket = SocketAdaptor.create(this);
|
||||
return socket;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getLocalAddress() throws IOException {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
return Net.getRevealedLocalAddress(localAddress);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getRemoteAddress() throws IOException {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
return remoteAddress;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,8 +219,7 @@ class SocketChannelImpl
|
|||
if (!supportedOptions().contains(name))
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
|
||||
if (name == StandardSocketOptions.IP_TOS) {
|
||||
|
@ -257,8 +238,6 @@ class SocketChannelImpl
|
|||
// no options that require special handling
|
||||
Net.setSocketOption(fd, name, value);
|
||||
return this;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,8 +250,7 @@ class SocketChannelImpl
|
|||
if (!supportedOptions().contains(name))
|
||||
throw new UnsupportedOperationException("'" + name + "' not supported");
|
||||
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
|
||||
if (name == StandardSocketOptions.SO_REUSEADDR && Net.useExclusiveBind()) {
|
||||
|
@ -289,8 +267,6 @@ class SocketChannelImpl
|
|||
|
||||
// no options that require special handling
|
||||
return (T) Net.getSocketOption(fd, name);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -332,13 +308,10 @@ class SocketChannelImpl
|
|||
// set hook for Thread.interrupt
|
||||
begin();
|
||||
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpenAndConnected();
|
||||
// record thread so it can be signalled if needed
|
||||
readerThread = NativeThread.current();
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
} else {
|
||||
ensureOpenAndConnected();
|
||||
|
@ -355,15 +328,11 @@ class SocketChannelImpl
|
|||
throws AsynchronousCloseException
|
||||
{
|
||||
if (blocking) {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
readerThread = 0;
|
||||
// notify any thread waiting in implCloseSelectableChannel
|
||||
if (state == ST_CLOSING) {
|
||||
stateCondition.signalAll();
|
||||
tryFinishClose();
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
// remove hook for Thread.interrupt
|
||||
end(completed);
|
||||
|
@ -467,15 +436,12 @@ class SocketChannelImpl
|
|||
// set hook for Thread.interrupt
|
||||
begin();
|
||||
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpenAndConnected();
|
||||
if (isOutputClosed)
|
||||
throw new ClosedChannelException();
|
||||
// record thread so it can be signalled if needed
|
||||
writerThread = NativeThread.current();
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
} else {
|
||||
ensureOpenAndConnected();
|
||||
|
@ -492,15 +458,11 @@ class SocketChannelImpl
|
|||
throws AsynchronousCloseException
|
||||
{
|
||||
if (blocking) {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
writerThread = 0;
|
||||
// notify any thread waiting in implCloseSelectableChannel
|
||||
if (state == ST_CLOSING) {
|
||||
stateCondition.signalAll();
|
||||
tryFinishClose();
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
// remove hook for Thread.interrupt
|
||||
end(completed);
|
||||
|
@ -613,12 +575,9 @@ class SocketChannelImpl
|
|||
*/
|
||||
private void lockedConfigureBlocking(boolean block) throws IOException {
|
||||
assert readLock.isHeldByCurrentThread() || writeLock.isHeldByCurrentThread();
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
IOUtil.configureBlocking(fd, block);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -626,11 +585,8 @@ class SocketChannelImpl
|
|||
* Returns the local address, or null if not bound
|
||||
*/
|
||||
InetSocketAddress localAddress() {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
return localAddress;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -638,11 +594,8 @@ class SocketChannelImpl
|
|||
* Returns the remote address, or null if not connected
|
||||
*/
|
||||
InetSocketAddress remoteAddress() {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
return remoteAddress;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -652,8 +605,7 @@ class SocketChannelImpl
|
|||
try {
|
||||
writeLock.lock();
|
||||
try {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
if (state == ST_CONNECTIONPENDING)
|
||||
throw new ConnectionPendingException();
|
||||
|
@ -668,8 +620,6 @@ class SocketChannelImpl
|
|||
NetHooks.beforeTcpBind(fd, isa.getAddress(), isa.getPort());
|
||||
Net.bind(fd, isa.getAddress(), isa.getPort());
|
||||
localAddress = Net.localAddress(fd);
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
} finally {
|
||||
writeLock.unlock();
|
||||
|
@ -706,8 +656,7 @@ class SocketChannelImpl
|
|||
// set hook for Thread.interrupt
|
||||
begin();
|
||||
}
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
int state = this.state;
|
||||
if (state == ST_CONNECTED)
|
||||
|
@ -725,8 +674,6 @@ class SocketChannelImpl
|
|||
// record thread so it can be signalled if needed
|
||||
readerThread = NativeThread.current();
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -743,14 +690,11 @@ class SocketChannelImpl
|
|||
endRead(blocking, completed);
|
||||
|
||||
if (completed) {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
if (state == ST_CONNECTIONPENDING) {
|
||||
localAddress = Net.localAddress(fd);
|
||||
state = ST_CONNECTED;
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -823,8 +767,7 @@ class SocketChannelImpl
|
|||
// set hook for Thread.interrupt
|
||||
begin();
|
||||
}
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
if (state != ST_CONNECTIONPENDING)
|
||||
throw new NoConnectionPendingException();
|
||||
|
@ -832,8 +775,6 @@ class SocketChannelImpl
|
|||
// record thread so it can be signalled if needed
|
||||
readerThread = NativeThread.current();
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -850,14 +791,11 @@ class SocketChannelImpl
|
|||
endRead(blocking, completed);
|
||||
|
||||
if (completed) {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
if (state == ST_CONNECTIONPENDING) {
|
||||
localAddress = Net.localAddress(fd);
|
||||
state = ST_CONNECTED;
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -904,90 +842,89 @@ class SocketChannelImpl
|
|||
}
|
||||
|
||||
/**
|
||||
* Invoked by implCloseChannel to close the channel.
|
||||
*
|
||||
* This method waits for outstanding I/O operations to complete. When in
|
||||
* blocking mode, the socket is pre-closed and the threads in blocking I/O
|
||||
* operations are signalled to ensure that the outstanding I/O operations
|
||||
* complete quickly.
|
||||
*
|
||||
* If the socket is connected then it is shutdown by this method. The
|
||||
* shutdown ensures that the peer reads EOF for the case that the socket is
|
||||
* not pre-closed or closed by this method.
|
||||
*
|
||||
* The socket is closed by this method when it is not registered with a
|
||||
* Selector. Note that a channel configured blocking may be registered with
|
||||
* a Selector. This arises when a key is canceled and the channel configured
|
||||
* to blocking mode before the key is flushed from the Selector.
|
||||
* Closes the socket if there are no I/O operations in progress and the
|
||||
* channel is not registered with a Selector.
|
||||
*/
|
||||
@Override
|
||||
protected void implCloseSelectableChannel() throws IOException {
|
||||
assert !isOpen();
|
||||
|
||||
boolean blocking;
|
||||
boolean connected;
|
||||
boolean interrupted = false;
|
||||
|
||||
// set state to ST_CLOSING
|
||||
stateLock.lock();
|
||||
try {
|
||||
assert state < ST_CLOSING;
|
||||
blocking = isBlocking();
|
||||
connected = (state == ST_CONNECTED);
|
||||
state = ST_CLOSING;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
private boolean tryClose() throws IOException {
|
||||
assert Thread.holdsLock(stateLock) && state == ST_CLOSING;
|
||||
if ((readerThread == 0) && (writerThread == 0) && !isRegistered()) {
|
||||
state = ST_CLOSED;
|
||||
nd.close(fd);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// wait for any outstanding I/O operations to complete
|
||||
if (blocking) {
|
||||
stateLock.lock();
|
||||
try {
|
||||
assert state == ST_CLOSING;
|
||||
/**
|
||||
* Invokes tryClose to attempt to close the socket.
|
||||
*
|
||||
* This method is used for deferred closing by I/O and Selector operations.
|
||||
*/
|
||||
private void tryFinishClose() {
|
||||
try {
|
||||
tryClose();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes this channel when configured in blocking mode.
|
||||
*
|
||||
* If there is an I/O operation in progress then the socket is pre-closed
|
||||
* and the I/O threads signalled, in which case the final close is deferred
|
||||
* until all I/O operations complete.
|
||||
*
|
||||
* Note that a channel configured blocking may be registered with a Selector
|
||||
* This arises when a key is canceled and the channel configured to blocking
|
||||
* mode before the key is flushed from the Selector.
|
||||
*/
|
||||
private void implCloseBlockingMode() throws IOException {
|
||||
synchronized (stateLock) {
|
||||
assert state < ST_CLOSING;
|
||||
state = ST_CLOSING;
|
||||
if (!tryClose()) {
|
||||
long reader = readerThread;
|
||||
long writer = writerThread;
|
||||
if (reader != 0 || writer != 0) {
|
||||
nd.preClose(fd);
|
||||
connected = false; // fd is no longer connected socket
|
||||
|
||||
if (reader != 0)
|
||||
NativeThread.signal(reader);
|
||||
if (writer != 0)
|
||||
NativeThread.signal(writer);
|
||||
|
||||
// wait for blocking I/O operations to end
|
||||
while (readerThread != 0 || writerThread != 0) {
|
||||
try {
|
||||
stateCondition.await();
|
||||
} catch (InterruptedException e) {
|
||||
interrupted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
} else {
|
||||
// non-blocking mode: wait for read/write to complete
|
||||
readLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
writeLock.unlock();
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set state to ST_KILLPENDING
|
||||
stateLock.lock();
|
||||
try {
|
||||
assert state == ST_CLOSING;
|
||||
// if connected and the channel is registered with a Selector then
|
||||
// shutdown the output if possible so that the peer reads EOF. If
|
||||
// SO_LINGER is enabled and set to a non-zero value then it needs to
|
||||
// be disabled so that the Selector does not wait when it closes
|
||||
// the socket.
|
||||
if (connected && isRegistered()) {
|
||||
/**
|
||||
* Closes this channel when configured in non-blocking mode.
|
||||
*
|
||||
* If the channel is registered with a Selector then the close is deferred
|
||||
* until the channel is flushed from all Selectors.
|
||||
*
|
||||
* If the socket is connected and the channel is registered with a Selector
|
||||
* then the socket is shutdown for writing so that the peer reads EOF. In
|
||||
* addition, if SO_LINGER is set to a non-zero value then it is disabled so
|
||||
* that the deferred close does not wait.
|
||||
*/
|
||||
private void implCloseNonBlockingMode() throws IOException {
|
||||
boolean connected;
|
||||
synchronized (stateLock) {
|
||||
assert state < ST_CLOSING;
|
||||
connected = (state == ST_CONNECTED);
|
||||
state = ST_CLOSING;
|
||||
}
|
||||
|
||||
// wait for any read/write operations to complete
|
||||
readLock.lock();
|
||||
readLock.unlock();
|
||||
writeLock.lock();
|
||||
writeLock.unlock();
|
||||
|
||||
// if the socket cannot be closed because it's registered with a Selector
|
||||
// then shutdown the socket for writing.
|
||||
synchronized (stateLock) {
|
||||
if (state == ST_CLOSING && !tryClose() && connected && isRegistered()) {
|
||||
try {
|
||||
SocketOption<Integer> opt = StandardSocketOptions.SO_LINGER;
|
||||
int interval = (int) Net.getSocketOption(fd, Net.UNSPEC, opt);
|
||||
|
@ -1000,37 +937,34 @@ class SocketChannelImpl
|
|||
}
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
state = ST_KILLPENDING;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// close socket if not registered with Selector
|
||||
if (!isRegistered())
|
||||
kill();
|
||||
|
||||
// restore interrupt status
|
||||
if (interrupted)
|
||||
Thread.currentThread().interrupt();
|
||||
/**
|
||||
* Invoked by implCloseChannel to close the channel.
|
||||
*/
|
||||
@Override
|
||||
protected void implCloseSelectableChannel() throws IOException {
|
||||
assert !isOpen();
|
||||
if (isBlocking()) {
|
||||
implCloseBlockingMode();
|
||||
} else {
|
||||
implCloseNonBlockingMode();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kill() throws IOException {
|
||||
stateLock.lock();
|
||||
try {
|
||||
if (state == ST_KILLPENDING) {
|
||||
state = ST_KILLED;
|
||||
nd.close(fd);
|
||||
public void kill() {
|
||||
synchronized (stateLock) {
|
||||
if (state == ST_CLOSING) {
|
||||
tryFinishClose();
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketChannel shutdownInput() throws IOException {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
if (!isConnected())
|
||||
throw new NotYetConnectedException();
|
||||
|
@ -1042,15 +976,12 @@ class SocketChannelImpl
|
|||
isInputClosed = true;
|
||||
}
|
||||
return this;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketChannel shutdownOutput() throws IOException {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
if (!isConnected())
|
||||
throw new NotYetConnectedException();
|
||||
|
@ -1062,8 +993,6 @@ class SocketChannelImpl
|
|||
isOutputClosed = true;
|
||||
}
|
||||
return this;
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1300,16 +1229,13 @@ class SocketChannelImpl
|
|||
* Return the number of bytes in the socket input buffer.
|
||||
*/
|
||||
int available() throws IOException {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
ensureOpenAndConnected();
|
||||
if (isInputClosed) {
|
||||
return 0;
|
||||
} else {
|
||||
return Net.available(fd);
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1389,8 +1315,7 @@ class SocketChannelImpl
|
|||
if (!isOpen())
|
||||
sb.append("closed");
|
||||
else {
|
||||
stateLock.lock();
|
||||
try {
|
||||
synchronized (stateLock) {
|
||||
switch (state) {
|
||||
case ST_UNCONNECTED:
|
||||
sb.append("unconnected");
|
||||
|
@ -1415,8 +1340,6 @@ class SocketChannelImpl
|
|||
sb.append(" remote=");
|
||||
sb.append(remoteAddress().toString());
|
||||
}
|
||||
} finally {
|
||||
stateLock.unlock();
|
||||
}
|
||||
}
|
||||
sb.append(']');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2019, 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
|
||||
|
@ -123,23 +123,40 @@ class URICertStore extends CertStoreSpi {
|
|||
// allowed when downloading CRLs
|
||||
private static final int DEFAULT_CRL_CONNECT_TIMEOUT = 15000;
|
||||
|
||||
// Default maximum read timeout in milliseconds (15 seconds)
|
||||
// allowed when downloading CRLs
|
||||
private static final int DEFAULT_CRL_READ_TIMEOUT = 15000;
|
||||
|
||||
/**
|
||||
* Integer value indicating the connect timeout, in seconds, to be
|
||||
* used for the CRL download. A timeout of zero is interpreted as
|
||||
* an infinite timeout.
|
||||
*/
|
||||
private static final int CRL_CONNECT_TIMEOUT = initializeTimeout();
|
||||
private static final int CRL_CONNECT_TIMEOUT =
|
||||
initializeTimeout("com.sun.security.crl.timeout",
|
||||
DEFAULT_CRL_CONNECT_TIMEOUT);
|
||||
|
||||
/**
|
||||
* Initialize the timeout length by getting the CRL timeout
|
||||
* system property. If the property has not been set, or if its
|
||||
* value is negative, set the timeout length to the default.
|
||||
* Integer value indicating the read timeout, in seconds, to be
|
||||
* used for the CRL download. A timeout of zero is interpreted as
|
||||
* an infinite timeout.
|
||||
*/
|
||||
private static int initializeTimeout() {
|
||||
Integer tmp = java.security.AccessController.doPrivileged(
|
||||
new GetIntegerAction("com.sun.security.crl.timeout"));
|
||||
private static final int CRL_READ_TIMEOUT =
|
||||
initializeTimeout("com.sun.security.crl.readtimeout",
|
||||
DEFAULT_CRL_READ_TIMEOUT);
|
||||
|
||||
/**
|
||||
* Initialize the timeout length by getting the specified CRL timeout
|
||||
* system property. If the property has not been set, or if its
|
||||
* value is negative, set the timeout length to the specified default.
|
||||
*/
|
||||
private static int initializeTimeout(String prop, int def) {
|
||||
Integer tmp = GetIntegerAction.privilegedGetProperty(prop);
|
||||
if (tmp == null || tmp < 0) {
|
||||
return DEFAULT_CRL_CONNECT_TIMEOUT;
|
||||
return def;
|
||||
}
|
||||
if (debug != null) {
|
||||
debug.println(prop + " set to " + tmp + " seconds");
|
||||
}
|
||||
// Convert to milliseconds, as the system property will be
|
||||
// specified in seconds
|
||||
|
@ -364,6 +381,7 @@ class URICertStore extends CertStoreSpi {
|
|||
}
|
||||
long oldLastModified = lastModified;
|
||||
connection.setConnectTimeout(CRL_CONNECT_TIMEOUT);
|
||||
connection.setReadTimeout(CRL_READ_TIMEOUT);
|
||||
try (InputStream in = connection.getInputStream()) {
|
||||
lastModified = connection.getLastModified();
|
||||
if (oldLastModified != 0) {
|
||||
|
|
|
@ -244,9 +244,8 @@ final class DTLSOutputRecord extends OutputRecord implements DTLSRecord {
|
|||
fragLen = Record.maxDataSize;
|
||||
}
|
||||
|
||||
if (fragmentSize > 0) {
|
||||
fragLen = Math.min(fragLen, fragmentSize);
|
||||
}
|
||||
// Calculate more impact, for example TLS 1.3 padding.
|
||||
fragLen = calculateFragmentSize(fragLen);
|
||||
|
||||
int dstPos = destination.position();
|
||||
int dstLim = destination.limit();
|
||||
|
@ -464,9 +463,8 @@ final class DTLSOutputRecord extends OutputRecord implements DTLSRecord {
|
|||
fragLen = Record.maxDataSize;
|
||||
}
|
||||
|
||||
if (fragmentSize > 0) {
|
||||
fragLen = Math.min(fragLen, fragmentSize);
|
||||
}
|
||||
// Calculate more impact, for example TLS 1.3 padding.
|
||||
fragLen = calculateFragmentSize(fragLen);
|
||||
|
||||
int dstPos = dstBuf.position();
|
||||
int dstLim = dstBuf.limit();
|
||||
|
|
|
@ -64,7 +64,7 @@ abstract class OutputRecord
|
|||
int packetSize;
|
||||
|
||||
// fragment size
|
||||
int fragmentSize;
|
||||
private int fragmentSize;
|
||||
|
||||
// closed or not?
|
||||
volatile boolean isClosed;
|
||||
|
@ -293,6 +293,24 @@ abstract class OutputRecord
|
|||
// shared helpers
|
||||
//
|
||||
|
||||
private static final class T13PaddingHolder {
|
||||
private static final byte[] zeros = new byte[16];
|
||||
}
|
||||
|
||||
int calculateFragmentSize(int fragmentLimit) {
|
||||
if (fragmentSize > 0) {
|
||||
fragmentLimit = Math.min(fragmentLimit, fragmentSize);
|
||||
}
|
||||
|
||||
if (protocolVersion.useTLS13PlusSpec()) {
|
||||
// No negative integer checking as the fragment capacity should
|
||||
// have been ensured.
|
||||
return fragmentLimit - T13PaddingHolder.zeros.length - 1;
|
||||
}
|
||||
|
||||
return fragmentLimit;
|
||||
}
|
||||
|
||||
// Encrypt a fragment and wrap up a record.
|
||||
//
|
||||
// To be consistent with the spec of SSLEngine.wrap() methods, the
|
||||
|
@ -374,8 +392,12 @@ abstract class OutputRecord
|
|||
if (!encCipher.isNullCipher()) {
|
||||
// inner plaintext, using zero length padding.
|
||||
int endOfPt = destination.limit();
|
||||
destination.limit(endOfPt + 1);
|
||||
destination.put(endOfPt, contentType);
|
||||
int startOfPt = destination.position();
|
||||
destination.position(endOfPt);
|
||||
destination.limit(endOfPt + 1 + T13PaddingHolder.zeros.length);
|
||||
destination.put(contentType);
|
||||
destination.put(T13PaddingHolder.zeros);
|
||||
destination.position(startOfPt);
|
||||
}
|
||||
|
||||
// use the right TLSCiphertext.opaque_type and legacy_record_version
|
||||
|
@ -443,10 +465,6 @@ abstract class OutputRecord
|
|||
}
|
||||
}
|
||||
|
||||
private static final class T13PaddingHolder {
|
||||
private static final byte[] zeros = new byte[16];
|
||||
}
|
||||
|
||||
private long t13Encrypt(
|
||||
SSLWriteCipher encCipher, byte contentType, int headerSize) {
|
||||
if (!encCipher.isNullCipher()) {
|
||||
|
|
|
@ -237,9 +237,8 @@ final class SSLEngineOutputRecord extends OutputRecord implements SSLRecord {
|
|||
fragLen = Record.maxDataSize;
|
||||
}
|
||||
|
||||
if (fragmentSize > 0) {
|
||||
fragLen = Math.min(fragLen, fragmentSize);
|
||||
}
|
||||
// Calculate more impact, for example TLS 1.3 padding.
|
||||
fragLen = calculateFragmentSize(fragLen);
|
||||
}
|
||||
|
||||
int dstPos = destination.position();
|
||||
|
@ -444,9 +443,8 @@ final class SSLEngineOutputRecord extends OutputRecord implements SSLRecord {
|
|||
fragLen = Record.maxDataSize;
|
||||
}
|
||||
|
||||
if (fragmentSize > 0) {
|
||||
fragLen = Math.min(fragLen, fragmentSize);
|
||||
}
|
||||
// Calculate more impact, for example TLS 1.3 padding.
|
||||
fragLen = calculateFragmentSize(fragLen);
|
||||
|
||||
int dstPos = dstBuf.position();
|
||||
int dstLim = dstBuf.limit();
|
||||
|
|
|
@ -312,9 +312,8 @@ final class SSLSocketOutputRecord extends OutputRecord implements SSLRecord {
|
|||
fragLen = Record.maxDataSize;
|
||||
}
|
||||
|
||||
if (fragmentSize > 0) {
|
||||
fragLen = Math.min(fragLen, fragmentSize);
|
||||
}
|
||||
// Calculate more impact, for example TLS 1.3 padding.
|
||||
fragLen = calculateFragmentSize(fragLen);
|
||||
|
||||
if (isFirstRecordOfThePayload && needToSplitPayload()) {
|
||||
fragLen = 1;
|
||||
|
@ -413,9 +412,8 @@ final class SSLSocketOutputRecord extends OutputRecord implements SSLRecord {
|
|||
fragLimit = Record.maxDataSize;
|
||||
}
|
||||
|
||||
if (fragmentSize > 0) {
|
||||
fragLimit = Math.min(fragLimit, fragmentSize);
|
||||
}
|
||||
// Calculate more impact, for example TLS 1.3 padding.
|
||||
fragLimit = calculateFragmentSize(fragLimit);
|
||||
|
||||
return fragLimit;
|
||||
}
|
||||
|
|
|
@ -3578,6 +3578,11 @@ public final class Main {
|
|||
{
|
||||
Key key = null;
|
||||
|
||||
if (KeyStoreUtil.isWindowsKeyStore(storetype)) {
|
||||
key = keyStore.getKey(alias, null);
|
||||
return Pair.of(key, null);
|
||||
}
|
||||
|
||||
if (keyStore.containsAlias(alias) == false) {
|
||||
MessageFormat form = new MessageFormat
|
||||
(rb.getString("Alias.alias.does.not.exist"));
|
||||
|
|
|
@ -1160,6 +1160,23 @@ jceks.key.serialFilter = java.base/java.lang.Enum;java.base/java.security.KeyRep
|
|||
#
|
||||
#jdk.includeInExceptions=hostInfo,jar
|
||||
|
||||
#
|
||||
# Disabled mechanisms for the Simple Authentication and Security Layer (SASL)
|
||||
#
|
||||
# Disabled mechanisms will not be negotiated by both SASL clients and servers.
|
||||
# These mechanisms will be ignored if they are specified in the mechanisms argument
|
||||
# of `Sasl.createClient` or the mechanism argument of `Sasl.createServer`.
|
||||
#
|
||||
# The value of this property is a comma-separated list of SASL mechanisms.
|
||||
# The mechanisms are case-sensitive. Whitespaces around the commas are ignored.
|
||||
#
|
||||
# Note: This property is currently used by the JDK Reference implementation.
|
||||
# It is not guaranteed to be examined and used by other implementations.
|
||||
#
|
||||
# Example:
|
||||
# jdk.sasl.disabledMechanisms=PLAIN, CRAM-MD5, DIGEST-MD5
|
||||
jdk.sasl.disabledMechanisms=
|
||||
|
||||
#
|
||||
# Policies for distrusting Certificate Authorities (CAs).
|
||||
#
|
||||
|
|
|
@ -1,25 +1,13 @@
|
|||
## Unicode Common Local Data Repository (CLDR) v33
|
||||
## Unicode Common Local Data Repository (CLDR) v35.1
|
||||
|
||||
### CLDR License
|
||||
|
||||
```
|
||||
|
||||
UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
|
||||
Unicode Data Files include all data files under the directories
|
||||
http://www.unicode.org/Public/, http://www.unicode.org/reports/,
|
||||
http://www.unicode.org/cldr/data/,
|
||||
http://source.icu-project.org/repos/icu/, and
|
||||
http://www.unicode.org/utility/trac/browser/.
|
||||
|
||||
Unicode Data Files do not include PDF online code charts under the
|
||||
directory http://www.unicode.org/Public/.
|
||||
|
||||
Software includes any source code published in the Unicode Standard
|
||||
or under the directories
|
||||
http://www.unicode.org/Public/, http://www.unicode.org/reports/,
|
||||
http://www.unicode.org/cldr/data/,
|
||||
http://source.icu-project.org/repos/icu/, and
|
||||
http://www.unicode.org/utility/trac/browser/.
|
||||
See Terms of Use for definitions of Unicode Inc.'s
|
||||
Data Files and Software.
|
||||
|
||||
NOTICE TO USER: Carefully read the following legal agreement.
|
||||
BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
|
||||
|
@ -31,8 +19,8 @@ THE DATA FILES OR SOFTWARE.
|
|||
|
||||
COPYRIGHT AND PERMISSION NOTICE
|
||||
|
||||
Copyright © 1991-2018 Unicode, Inc. All rights reserved.
|
||||
Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
|
||||
Copyright © 1991-2019 Unicode, Inc. All rights reserved.
|
||||
Distributed under the Terms of Use in https://www.unicode.org/copyright.html.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Unicode data files and any associated documentation
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, 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
|
||||
|
@ -46,9 +46,4 @@ JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) {
|
|||
((version_security & 0xFF) << 8) |
|
||||
(version_build & 0xFF);
|
||||
info->patch_version = version_patch;
|
||||
info->thread_park_blocker = 1;
|
||||
// Advertise presence of PostVMInitHook:
|
||||
// future optimization: detect if this is enabled.
|
||||
info->post_vm_init_hook_enabled = 1;
|
||||
info->pending_list_uses_discovered_field = 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue