Skip to content

Commit

Permalink
Make sure SslHandler also works if SslBufferPool use non heap ByteBuf…
Browse files Browse the repository at this point in the history
…fers. See #329
  • Loading branch information
normanmaurer committed May 18, 2012
1 parent ef384a7 commit a99f258
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions handler/src/main/java/io/netty/handler/ssl/SslHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,14 @@ private ChannelFuture wrap(ChannelHandlerContext context, Channel channel)

if (result.bytesProduced() > 0) {
outNetBuf.flip();
msg = ChannelBuffers.buffer(outNetBuf.remaining());
msg.writeBytes(outNetBuf.array(), 0, msg.capacity());
int remaining = outNetBuf.remaining();
msg = ChannelBuffers.buffer(remaining);

// Transfer the bytes to the new ChannelBuffer using some safe method that will also
// work with "non" heap buffers
//
// See https://github.com/netty/netty/issues/329
msg.writeBytes(outNetBuf);
outNetBuf.clear();

if (pendingWrite.outAppBuf.hasRemaining()) {
Expand Down Expand Up @@ -850,7 +856,12 @@ private ChannelFuture wrapNonAppData(ChannelHandlerContext ctx, Channel channel)
if (result.bytesProduced() > 0) {
outNetBuf.flip();
ChannelBuffer msg = ChannelBuffers.buffer(outNetBuf.remaining());
msg.writeBytes(outNetBuf.array(), 0, msg.capacity());

// Transfer the bytes to the new ChannelBuffer using some safe method that will also
// work with "non" heap buffers
//
// See https://github.com/netty/netty/issues/329
msg.writeBytes(outNetBuf);
outNetBuf.clear();

future = future(channel);
Expand Down Expand Up @@ -993,7 +1004,12 @@ private ChannelBuffer unwrap(

if (outAppBuf.hasRemaining()) {
ChannelBuffer frame = ctx.getChannel().getConfig().getBufferFactory().getBuffer(outAppBuf.remaining());
frame.writeBytes(outAppBuf.array(), 0, frame.capacity());
// Transfer the bytes to the new ChannelBuffer using some safe method that will also
// work with "non" heap buffers
//
// See https://github.com/netty/netty/issues/329
frame.writeBytes(outAppBuf);

return frame;
} else {
return null;
Expand Down

0 comments on commit a99f258

Please sign in to comment.