Merge branch '3.2' of github.com:netty/netty into 3.2
This commit is contained in:
commit
97646745c1
@ -207,17 +207,28 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
ChannelBuffer cumulation = cumulation(ctx);
|
||||
if (cumulation.readable()) {
|
||||
cumulation.discardReadBytes();
|
||||
cumulation.writeBytes(input);
|
||||
callDecode(ctx, e.getChannel(), cumulation, e.getRemoteAddress());
|
||||
} else {
|
||||
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);
|
||||
if (cumulation.readable()) {
|
||||
cumulation.discardReadBytes();
|
||||
cumulation.writeBytes(input);
|
||||
callDecode(ctx, e.getChannel(), cumulation, e.getRemoteAddress());
|
||||
} else {
|
||||
callDecode(ctx, e.getChannel(), input, e.getRemoteAddress());
|
||||
if (input.readable()) {
|
||||
cumulation.writeBytes(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -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) {
|
||||
ChannelBuffer c = cumulation;
|
||||
if (c == null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user