mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-12-11 11:34:18 +01:00
0dc74bb242
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing BungeeCord Changes: dfd847f7 Update native libraries a1fee720 Deprecate string join 963854f8 Remove use of internal gson API 2ef5e700 #3451: Improve length field prepending on bungee -> server connection 2e6f0dd4 #3450: Use readRetainedSlice method instead of slice+retain+skip
71 lines
2.7 KiB
Diff
71 lines
2.7 KiB
Diff
From bc1b94faf6edb72a90f148a3638fff1de2eabcf4 Mon Sep 17 00:00:00 2001
|
|
From: creeper123123321 <creeper123123321@gmail.com>
|
|
Date: Thu, 17 Jan 2019 03:25:59 +0000
|
|
Subject: [PATCH] Don't use a bytebuf for packet decoding
|
|
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
|
|
index cf7dea17..3a802ca4 100644
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
|
|
@@ -27,8 +27,7 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
|
|
|
|
in.markReaderIndex();
|
|
|
|
- final byte[] buf = new byte[ 3 ];
|
|
- for ( int i = 0; i < buf.length; i++ )
|
|
+ for ( int i = 0; i < 3; i++ ) // Waterfall
|
|
{
|
|
if ( !in.isReadable() )
|
|
{
|
|
@@ -36,10 +35,13 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
|
|
return;
|
|
}
|
|
|
|
- buf[i] = in.readByte();
|
|
- if ( buf[i] >= 0 )
|
|
+ // Waterfall start
|
|
+ byte read = in.readByte();
|
|
+ if ( read >= 0 )
|
|
{
|
|
- int length = DefinedPacket.readVarInt( Unpooled.wrappedBuffer( buf ) );
|
|
+ in.resetReaderIndex();
|
|
+ int length = DefinedPacket.readVarInt( in );
|
|
+ // Waterfall end
|
|
if ( false && length == 0) // Waterfall - ignore
|
|
{
|
|
throw new CorruptedFrameException( "Empty Packet!" );
|
|
@@ -49,25 +51,11 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
|
|
{
|
|
in.resetReaderIndex();
|
|
return;
|
|
- } else
|
|
- {
|
|
- if ( in.hasMemoryAddress() )
|
|
- {
|
|
- out.add( in.readRetainedSlice( length ) );
|
|
- } else
|
|
- {
|
|
- if ( !DIRECT_WARNING )
|
|
- {
|
|
- DIRECT_WARNING = true;
|
|
- System.out.println( "Netty is not using direct IO buffers." );
|
|
- }
|
|
-
|
|
- // See https://github.com/SpigotMC/BungeeCord/issues/1717
|
|
- ByteBuf dst = ctx.alloc().directBuffer( length );
|
|
- in.readBytes( dst );
|
|
- out.add( dst );
|
|
- }
|
|
+ // Waterfall start
|
|
+ } else {
|
|
+ out.add(in.readRetainedSlice(length));
|
|
return;
|
|
+ // Waterfall end
|
|
}
|
|
}
|
|
}
|
|
--
|
|
2.40.0
|
|
|