Only parse the packet length one time per packet. See #382
This commit is contained in:
parent
977ce4e645
commit
784722eff4
@ -199,6 +199,8 @@ public class SslHandler extends FrameDecoder
|
|||||||
|
|
||||||
private final SSLEngineInboundCloseFuture sslEngineCloseFuture = new SSLEngineInboundCloseFuture();
|
private final SSLEngineInboundCloseFuture sslEngineCloseFuture = new SSLEngineInboundCloseFuture();
|
||||||
|
|
||||||
|
private int packetLength = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
*
|
*
|
||||||
@ -572,12 +574,11 @@ public class SslHandler extends FrameDecoder
|
|||||||
protected Object decode(
|
protected Object decode(
|
||||||
final ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
|
final ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
|
||||||
|
|
||||||
|
if (packetLength == -1) {
|
||||||
if (buffer.readableBytes() < 5) {
|
if (buffer.readableBytes() < 5) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int packetLength = 0;
|
|
||||||
|
|
||||||
// SSLv3 or TLS - Check ContentType
|
// SSLv3 or TLS - Check ContentType
|
||||||
boolean tls;
|
boolean tls;
|
||||||
switch (buffer.getUnsignedByte(buffer.readerIndex())) {
|
switch (buffer.getUnsignedByte(buffer.readerIndex())) {
|
||||||
@ -639,6 +640,8 @@ public class SslHandler extends FrameDecoder
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert packetLength > 0;
|
assert packetLength > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (buffer.readableBytes() < packetLength) {
|
if (buffer.readableBytes() < packetLength) {
|
||||||
return null;
|
return null;
|
||||||
@ -660,7 +663,11 @@ public class SslHandler extends FrameDecoder
|
|||||||
// before calling the user code.
|
// before calling the user code.
|
||||||
final int packetOffset = buffer.readerIndex();
|
final int packetOffset = buffer.readerIndex();
|
||||||
buffer.skipBytes(packetLength);
|
buffer.skipBytes(packetLength);
|
||||||
|
try {
|
||||||
return unwrap(ctx, channel, buffer, packetOffset, packetLength);
|
return unwrap(ctx, channel, buffer, packetOffset, packetLength);
|
||||||
|
} finally {
|
||||||
|
packetLength = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user