Skip to content

Commit

Permalink
Make sure channelInactive() and channelDeregistered() are triggered e…
Browse files Browse the repository at this point in the history
…ven if outboundBuffer.recycle() fails
  • Loading branch information
trustin committed Jul 18, 2013
1 parent 7215c01 commit fef838f
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions transport/src/main/java/io/netty/channel/AbstractChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -523,22 +523,25 @@ public void run() {
}

// fail all queued messages
ChannelOutboundBuffer outboundBuffer = this.outboundBuffer;
outboundBuffer.failFlushed(CLOSED_CHANNEL_EXCEPTION);
outboundBuffer.failUnflushed(CLOSED_CHANNEL_EXCEPTION);
outboundBuffer.recycle();
this.outboundBuffer = null;
try {
ChannelOutboundBuffer outboundBuffer = this.outboundBuffer;
outboundBuffer.failFlushed(CLOSED_CHANNEL_EXCEPTION);
outboundBuffer.failUnflushed(CLOSED_CHANNEL_EXCEPTION);
outboundBuffer.recycle();
} finally {
outboundBuffer = null;

if (wasActive && !isActive()) {
invokeLater(new Runnable() {
@Override
public void run() {
pipeline.fireChannelInactive();
}
});
}

if (wasActive && !isActive()) {
invokeLater(new Runnable() {
@Override
public void run() {
pipeline.fireChannelInactive();
}
});
deregister(voidPromise());
}

deregister(voidPromise());
} else {
// Closed already.
promise.setSuccess();
Expand Down

0 comments on commit fef838f

Please sign in to comment.