SslHander wrap conditional direct buffer allocation
Motivation: The SslHandler currently forces the use of a direct buffer for the input to the SSLEngine.wrap(..) operation. This allocation may not always be desired and should be conditionally done. Modifications: - Use the pre-existing wantsDirectBuffer variable as the condition to do the conversion. Result: - An allocation of a direct byte buffer and a copy of data is now not required for every SslHandler wrap operation.
This commit is contained in:
parent
1914b77c71
commit
e73f32b52d
@ -182,7 +182,7 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
|
|||||||
// BEGIN Platform-dependent flags
|
// BEGIN Platform-dependent flags
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code trus} if and only if {@link SSLEngine} expects a direct buffer.
|
* {@code true} if and only if {@link SSLEngine} expects a direct buffer.
|
||||||
*/
|
*/
|
||||||
private final boolean wantsDirectBuffer;
|
private final boolean wantsDirectBuffer;
|
||||||
/**
|
/**
|
||||||
@ -581,7 +581,7 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
|
|||||||
ByteBuf newDirectIn = null;
|
ByteBuf newDirectIn = null;
|
||||||
try {
|
try {
|
||||||
final ByteBuffer in0;
|
final ByteBuffer in0;
|
||||||
if (in.isDirect()) {
|
if (in.isDirect() || !wantsDirectBuffer) {
|
||||||
in0 = in.nioBuffer();
|
in0 = in.nioBuffer();
|
||||||
} else {
|
} else {
|
||||||
int readableBytes = in.readableBytes();
|
int readableBytes = in.readableBytes();
|
||||||
|
Loading…
Reference in New Issue
Block a user