Call discardReadBytes() on outbound byte buffers when possible

- Also fixed a test failure in codec-http
This commit is contained in:
Trustin Lee 2012-05-31 16:59:54 -07:00
parent d626561b59
commit f2eddda5a4
3 changed files with 9 additions and 1 deletions

View File

@ -626,6 +626,9 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
cause = t;
} finally {
writeCounter += oldSize - out.size();
if (out.isEmpty() && out.hasByteBuffer()) {
out.byteBuffer().discardReadBytes();
}
}
if (cause == null) {

View File

@ -323,7 +323,7 @@ public class DefaultChannelFuture extends FlushCheckpoint implements ChannelFutu
}
private void checkDeadLock() {
if (channel().eventLoop().inEventLoop()) {
if (channel().isRegistered() && channel().eventLoop().inEventLoop()) {
throw new BlockingOperationException();
}
}

View File

@ -927,6 +927,11 @@ public class DefaultChannelPipeline implements ChannelPipeline {
((ChannelOutboundHandler<Object>) ctx.handler()).flush(ctx, future);
} catch (Throwable t) {
notifyHandlerException(t);
} finally {
ChannelBufferHolder<Object> outbound = ctx.outbound();
if (!outbound.isBypass() && outbound.isEmpty() && outbound.hasByteBuffer()) {
outbound.byteBuffer().discardReadBytes();
}
}
} else {
channel().unsafe().flush(future);