Merge branch '3.2' of github.com:netty/netty into 3.2

This commit is contained in:
Trustin Lee 2011-12-03 19:56:13 +09:00
commit 97646745c1

View File

@ -207,6 +207,15 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler {
return; return;
} }
if (cumulation == null) {
// the cumulation buffer is not created yet so just pass the input to callDecode(...) method
callDecode(ctx, e.getChannel(), input, e.getRemoteAddress());
if (input.readable()) {
// seems like there is something readable left in the input buffer. So create the cumulation buffer and copy the input into it
ChannelBuffer cumulation = cumulation(ctx);
cumulation.writeBytes(input);
}
} else {
ChannelBuffer cumulation = cumulation(ctx); ChannelBuffer cumulation = cumulation(ctx);
if (cumulation.readable()) { if (cumulation.readable()) {
cumulation.discardReadBytes(); cumulation.discardReadBytes();
@ -220,6 +229,8 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler {
} }
} }
}
@Override @Override
public void channelDisconnected( public void channelDisconnected(
ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
@ -349,6 +360,12 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler {
} }
} }
/**
* Get the currently used {@link ChannelBuffer} for cumulation or create one in a lazy fashion if none exist yet
*
* @param ctx the {@link ChannelHandlerContext} for this handler
* @return buffer the {@link ChannelBuffer} which is used fo cumulation
*/
private ChannelBuffer cumulation(ChannelHandlerContext ctx) { private ChannelBuffer cumulation(ChannelHandlerContext ctx) {
ChannelBuffer c = cumulation; ChannelBuffer c = cumulation;
if (c == null) { if (c == null) {