From 5f6808db9a30928b8f1fdb145208d591ab6c7121 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 5 Jul 2020 22:38:18 -0400 Subject: [PATCH] Optimize NetworkManager Exception Handling --- .../network/Varint21FrameDecoder.java.patch | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 paper-server/patches/sources/net/minecraft/network/Varint21FrameDecoder.java.patch diff --git a/paper-server/patches/sources/net/minecraft/network/Varint21FrameDecoder.java.patch b/paper-server/patches/sources/net/minecraft/network/Varint21FrameDecoder.java.patch new file mode 100644 index 0000000000..e9aad632b1 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/network/Varint21FrameDecoder.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/network/Varint21FrameDecoder.java ++++ b/net/minecraft/network/Varint21FrameDecoder.java +@@ -39,6 +39,12 @@ + } + + protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List list) { ++ // Paper start - Perf: Optimize exception handling; if channel is not active just discard the packet ++ if (!channelHandlerContext.channel().isActive()) { ++ byteBuf.skipBytes(byteBuf.readableBytes()); ++ return; ++ } ++ // Paper end - Perf: Optimize exception handling + byteBuf.markReaderIndex(); + this.helperBuf.clear(); + if (!copyVarint(byteBuf, this.helperBuf)) {