3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Try to diagnose memory leak

Dieser Commit ist enthalten in:
Andrew Steinborn 2019-12-31 21:43:02 -05:00
Ursprung 2073d79771
Commit 08df080771
2 geänderte Dateien mit 8 neuen und 25 gelöschten Zeilen

Datei anzeigen

@ -22,7 +22,6 @@ public class MinecraftCipherDecoder extends MessageToMessageDecoder<ByteBuf> {
try {
cipher.process(compatible);
out.add(compatible);
in.skipBytes(in.readableBytes());
} catch (Exception e) {
compatible.release(); // compatible will never be used if we throw an exception
throw e;

Datei anzeigen

@ -4,38 +4,22 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.CorruptedFrameException;
import java.util.List;
public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
read_lens: while (in.isReadable()) {
int origReaderIndex = in.readerIndex();
for (int i = 0; i < 3; i++) {
if (!in.isReadable()) {
in.readerIndex(origReaderIndex);
return;
}
while (in.isReadable()) {
int ri = in.readerIndex();
int packetLength = ProtocolUtils.readVarInt(in);
byte read = in.readByte();
if (read >= 0) {
// Make sure reader index of length buffer is returned to the beginning
in.readerIndex(origReaderIndex);
int packetLength = ProtocolUtils.readVarInt(in);
if (in.readableBytes() >= packetLength) {
out.add(in.readRetainedSlice(packetLength));
continue read_lens;
} else {
in.readerIndex(origReaderIndex);
return;
}
}
if (in.readableBytes() >= packetLength) {
out.add(in.readBytes(packetLength));
} else {
in.readerIndex(ri);
break;
}
throw new CorruptedFrameException("VarInt too big");
}
}
}