Replaced flag update methods with simple assignment
This commit is contained in:
parent
4668cb792e
commit
0acffadd29
@ -45,7 +45,7 @@ final class NioAcceptedSocketChannel extends NioSocketChannel {
|
|||||||
|
|
||||||
this.bossThread = bossThread;
|
this.bossThread = bossThread;
|
||||||
|
|
||||||
setConnected();
|
state = NioSocketChannel.ST_CONNECTED;
|
||||||
fireChannelOpen(this);
|
fireChannelOpen(this);
|
||||||
fireChannelBound(this, getLocalAddress());
|
fireChannelBound(this, getLocalAddress());
|
||||||
fireChannelConnected(this, getRemoteAddress());
|
fireChannelConnected(this, getRemoteAddress());
|
||||||
|
@ -124,7 +124,7 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
|
|||||||
try {
|
try {
|
||||||
channel.socket.socket().bind(localAddress);
|
channel.socket.socket().bind(localAddress);
|
||||||
channel.boundManually = true;
|
channel.boundManually = true;
|
||||||
channel.setBound();
|
channel.state = NioSocketChannel.ST_BOUND;
|
||||||
future.setSuccess();
|
future.setSuccess();
|
||||||
fireChannelBound(channel, channel.getLocalAddress());
|
fireChannelBound(channel, channel.getLocalAddress());
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
@ -45,11 +45,11 @@ import org.jboss.netty.util.internal.ThreadLocalBoolean;
|
|||||||
class NioSocketChannel extends AbstractChannel
|
class NioSocketChannel extends AbstractChannel
|
||||||
implements org.jboss.netty.channel.socket.SocketChannel {
|
implements org.jboss.netty.channel.socket.SocketChannel {
|
||||||
|
|
||||||
private static final int ST_OPEN = 0;
|
static final int ST_OPEN = 0;
|
||||||
private static final int ST_BOUND = 1;
|
static final int ST_BOUND = 1;
|
||||||
private static final int ST_CONNECTED = 2;
|
static final int ST_CONNECTED = 2;
|
||||||
private static final int ST_CLOSED = -1;
|
static final int ST_CLOSED = -1;
|
||||||
private volatile int state = ST_OPEN;
|
volatile int state = ST_OPEN;
|
||||||
|
|
||||||
final SocketChannel socket;
|
final SocketChannel socket;
|
||||||
final NioWorker worker;
|
final NioWorker worker;
|
||||||
@ -127,24 +127,10 @@ class NioSocketChannel extends AbstractChannel
|
|||||||
return state == ST_CONNECTED;
|
return state == ST_CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
final void setBound() {
|
|
||||||
assert state == ST_OPEN;
|
|
||||||
state = ST_BOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
final void setConnected() {
|
|
||||||
assert state == ST_OPEN || state == ST_BOUND;
|
|
||||||
state = ST_CONNECTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean setClosed() {
|
protected boolean setClosed() {
|
||||||
setClosedFlag();
|
|
||||||
return super.setClosed();
|
|
||||||
}
|
|
||||||
|
|
||||||
final void setClosedFlag() {
|
|
||||||
state = ST_CLOSED;
|
state = ST_CLOSED;
|
||||||
|
return super.setClosed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -327,7 +327,7 @@ class NioWorker implements Runnable {
|
|||||||
failure = false;
|
failure = false;
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
if (!ch.isConnected()) {
|
if (!ch.isConnected()) {
|
||||||
channel.setClosedFlag();
|
channel.state = NioSocketChannel.ST_CLOSED;
|
||||||
}
|
}
|
||||||
if (t instanceof AsynchronousCloseException) {
|
if (t instanceof AsynchronousCloseException) {
|
||||||
// Can happen, and does not need a user attention.
|
// Can happen, and does not need a user attention.
|
||||||
@ -475,7 +475,7 @@ class NioWorker implements Runnable {
|
|||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
if (!channel.socket.isConnected()) {
|
if (!channel.socket.isConnected()) {
|
||||||
channel.setClosedFlag();
|
channel.state = NioSocketChannel.ST_CLOSED;
|
||||||
}
|
}
|
||||||
if (t instanceof AsynchronousCloseException) {
|
if (t instanceof AsynchronousCloseException) {
|
||||||
// Doesn't need a user attention - ignore.
|
// Doesn't need a user attention - ignore.
|
||||||
@ -782,7 +782,7 @@ class NioWorker implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!server) {
|
if (!server) {
|
||||||
channel.setConnected();
|
channel.state = NioSocketChannel.ST_CONNECTED;
|
||||||
if (!((NioClientSocketChannel) channel).boundManually) {
|
if (!((NioClientSocketChannel) channel).boundManually) {
|
||||||
fireChannelBound(channel, localAddress);
|
fireChannelBound(channel, localAddress);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user