mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-22 23:10:52 +01:00
Merge branch 'patch-netty-memory-leak' into 'dev'
Fix #915 : netty memory leak See merge request morningstar/Arcturus-Community!338
This commit is contained in:
commit
1bb8719cab
@ -17,13 +17,13 @@ public class GameByteDecryption extends ByteToMessageDecoder {
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
|
||||
// Read all available bytes.
|
||||
byte[] data = in.readBytes(in.readableBytes()).array();
|
||||
ByteBuf data = in.readBytes(in.readableBytes());
|
||||
|
||||
// Decrypt.
|
||||
ctx.channel().attr(GameServerAttributes.CRYPTO_CLIENT).get().parse(data);
|
||||
ctx.channel().attr(GameServerAttributes.CRYPTO_CLIENT).get().parse(data.array());
|
||||
|
||||
// Continue in the pipeline.
|
||||
out.add(Unpooled.wrappedBuffer(data));
|
||||
out.add(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,28 +6,25 @@ import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelOutboundHandlerAdapter;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
|
||||
public class GameByteEncryption extends ChannelOutboundHandlerAdapter {
|
||||
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||
// Convert msg to ByteBuf.
|
||||
ByteBuf out = (ByteBuf) msg;
|
||||
// convert to Bytebuf
|
||||
ByteBuf in = (ByteBuf) msg;
|
||||
|
||||
// Read all available bytes.
|
||||
byte[] data;
|
||||
// read available bytes
|
||||
ByteBuf data = (in).readBytes(in.readableBytes());
|
||||
|
||||
if (out.hasArray()) {
|
||||
data = out.array();
|
||||
} else {
|
||||
data = out.readBytes(out.readableBytes()).array();
|
||||
}
|
||||
//release old object
|
||||
ReferenceCountUtil.release(in);
|
||||
|
||||
// Encrypt.
|
||||
ctx.channel().attr(GameServerAttributes.CRYPTO_SERVER).get().parse(data);
|
||||
ctx.channel().attr(GameServerAttributes.CRYPTO_SERVER).get().parse(data.array());
|
||||
|
||||
// Continue in the pipeline.
|
||||
ctx.write(Unpooled.wrappedBuffer(data));
|
||||
ctx.write(data, promise);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user