< prev index next > src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java
Print this page
private static final int ST_CLOSING = 1;
private static final int ST_CLOSED = 2;
private int state;
// ID of native thread currently blocked in this channel, for signalling
! private long thread;
// Binding
private SocketAddress localAddress; // null => unbound
// set true when exclusive binding is on and SO_REUSEADDR is emulated
private static final int ST_CLOSING = 1;
private static final int ST_CLOSED = 2;
private int state;
// ID of native thread currently blocked in this channel, for signalling
! private NativeThread thread;
// Binding
private SocketAddress localAddress; // null => unbound
// set true when exclusive binding is on and SO_REUSEADDR is emulated
private void end(boolean blocking, boolean completed)
throws AsynchronousCloseException
{
if (blocking) {
synchronized (stateLock) {
! thread = 0;
if (state == ST_CLOSING) {
tryFinishClose();
}
}
end(completed);
private void end(boolean blocking, boolean completed)
throws AsynchronousCloseException
{
if (blocking) {
synchronized (stateLock) {
! thread = null;
if (state == ST_CLOSING) {
tryFinishClose();
}
}
end(completed);
* 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;
* 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 == null) && !isRegistered()) {
state = ST_CLOSED;
nd.close(fd);
return true;
} else {
return false;
private void implCloseBlockingMode() throws IOException {
synchronized (stateLock) {
assert state < ST_CLOSING;
state = ST_CLOSING;
if (!tryClose()) {
! nd.preClose(fd, thread, 0);
}
}
}
/**
private void implCloseBlockingMode() throws IOException {
synchronized (stateLock) {
assert state < ST_CLOSING;
state = ST_CLOSING;
if (!tryClose()) {
! nd.preClose(fd, thread, null);
}
}
}
/**
< prev index next >