Fixed large packet handling (#9147)

Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
This commit is contained in:
Lukas Alt 2023-04-27 20:50:14 +02:00 committed by GitHub
parent f4ce997a42
commit bcec5b11e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 56 additions and 44 deletions

View File

@ -7,16 +7,19 @@ If a players inventory is too big to send in a single packet,
split the inventory set into multiple packets instead. split the inventory set into multiple packets instead.
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index b1a9c75081f7e61212ea9395b35375e067fd7fc6..f70d81e1a779da840b636b36a913a0dca9427c94 100644 index b1a9c75081f7e61212ea9395b35375e067fd7fc6..6f903ad884db68f654a9f2501e336123699c11a3 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -152,6 +152,15 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -152,6 +152,18 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
} }
public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) { public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) {
+ // Paper start + // Paper start
+ if (throwable instanceof io.netty.handler.codec.EncoderException && throwable.getCause() instanceof PacketEncoder.PacketTooLargeException) { + if (throwable instanceof io.netty.handler.codec.EncoderException && throwable.getCause() instanceof PacketEncoder.PacketTooLargeException packetTooLargeException) {
+ if (((PacketEncoder.PacketTooLargeException) throwable.getCause()).getPacket().packetTooLarge(this)) { + if (packetTooLargeException.getPacket().packetTooLarge(this)) {
+ return;
+ } else if (packetTooLargeException.getPacket().isSkippable()) {
+ Connection.LOGGER.debug("Skipping packet due to errors", throwable.getCause());
+ return; + return;
+ } else { + } else {
+ throwable = throwable.getCause(); + throwable = throwable.getCause();
@ -27,9 +30,18 @@ index b1a9c75081f7e61212ea9395b35375e067fd7fc6..f70d81e1a779da840b636b36a913a0dc
Connection.LOGGER.debug("Skipping packet due to errors", throwable.getCause()); Connection.LOGGER.debug("Skipping packet due to errors", throwable.getCause());
} else { } else {
diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java
index 42828edf81bd475b673a9d143f79c0d0711f14f5..ebee957fb048da6ffcd2a5ba2ed989ed1a6634e9 100644 index 42828edf81bd475b673a9d143f79c0d0711f14f5..fbfadeb83719b81f42724e79c59e92ed88fdece7 100644
--- a/src/main/java/net/minecraft/network/PacketEncoder.java --- a/src/main/java/net/minecraft/network/PacketEncoder.java
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java +++ b/src/main/java/net/minecraft/network/PacketEncoder.java
@@ -40,7 +40,7 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
int j = friendlyByteBuf.writerIndex();
packet.write(friendlyByteBuf);
int k = friendlyByteBuf.writerIndex() - j;
- if (k > 8388608) {
+ if (false && k > 8388608) { // Paper - disable
throw new IllegalArgumentException("Packet too big (is " + k + ", should be less than 8388608): " + packet);
} else {
int l = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().getId();
@@ -54,7 +54,31 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> { @@ -54,7 +54,31 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
throw var10; throw var10;
} }
@ -46,7 +58,7 @@ index 42828edf81bd475b673a9d143f79c0d0711f14f5..ebee957fb048da6ffcd2a5ba2ed989ed
} }
+ +
+ // Paper start + // Paper start
+ private static int MAX_PACKET_SIZE = 2097152; + private static int MAX_PACKET_SIZE = 8388608;
+ +
+ public static class PacketTooLargeException extends RuntimeException { + public static class PacketTooLargeException extends RuntimeException {
+ private final Packet<?> packet; + private final Packet<?> packet;

View File

@ -39,10 +39,10 @@ public net.minecraft.server.network.ServerLoginPacketListenerImpl state
public net.minecraft.server.network.ServerLoginPacketListenerImpl gameProfile public net.minecraft.server.network.ServerLoginPacketListenerImpl gameProfile
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index f70d81e1a779da840b636b36a913a0dca9427c94..62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa 100644 index 6f903ad884db68f654a9f2501e336123699c11a3..e1eea381a2ebcc32424d31c42a45287d2a1cb16a 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -487,6 +487,26 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -490,6 +490,26 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
this.getPacketListener().onDisconnect(Component.translatable("multiplayer.disconnect.generic")); this.getPacketListener().onDisconnect(Component.translatable("multiplayer.disconnect.generic"));
} }
this.queue.clear(); // Free up packet queue. this.queue.clear(); // Free up packet queue.

View File

@ -28,7 +28,7 @@ and then catch exceptions and close if they fire.
Part of this commit was authored by: Spottedleaf, sandtechnology Part of this commit was authored by: Spottedleaf, sandtechnology
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc29449cf5c 100644 index e1eea381a2ebcc32424d31c42a45287d2a1cb16a..ca9a36e357e73b1b518ebb5c937314269655de32 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -118,6 +118,10 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -118,6 +118,10 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@ -50,7 +50,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2
this.channel.attr(Connection.ATTRIBUTE_PROTOCOL).set(state); this.channel.attr(Connection.ATTRIBUTE_PROTOCOL).set(state);
this.channel.attr(BundlerInfo.BUNDLER_PROVIDER).set(state); this.channel.attr(BundlerInfo.BUNDLER_PROVIDER).set(state);
this.channel.config().setAutoRead(true); this.channel.config().setAutoRead(true);
@@ -220,19 +225,88 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -223,19 +228,88 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
Validate.notNull(listener, "packetListener", new Object[0]); Validate.notNull(listener, "packetListener", new Object[0]);
this.packetListener = listener; this.packetListener = listener;
} }
@ -143,7 +143,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2
} }
private void sendPacket(Packet<?> packet, @Nullable PacketSendListener callbacks) { private void sendPacket(Packet<?> packet, @Nullable PacketSendListener callbacks) {
@@ -264,6 +338,15 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -267,6 +341,15 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
this.setProtocol(packetState); this.setProtocol(packetState);
} }
@ -159,7 +159,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2
ChannelFuture channelfuture = this.channel.writeAndFlush(packet); ChannelFuture channelfuture = this.channel.writeAndFlush(packet);
if (callbacks != null) { if (callbacks != null) {
@@ -282,28 +365,72 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -285,28 +368,72 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
}); });
} }
@ -240,7 +240,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2
} finally { // Paper start - add pending task queue } finally { // Paper start - add pending task queue
Runnable r; Runnable r;
while ((r = this.pendingTasks.poll()) != null) { while ((r = this.pendingTasks.poll()) != null) {
@@ -311,6 +438,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -314,6 +441,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
} }
} // Paper end - add pending task queue } // Paper end - add pending task queue
} }
@ -248,7 +248,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2
public void tick() { public void tick() {
this.flushQueue(); this.flushQueue();
@@ -347,9 +475,22 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -350,9 +478,22 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
return this.address; return this.address;
} }
@ -271,7 +271,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2
// Spigot End // Spigot End
if (this.channel.isOpen()) { if (this.channel.isOpen()) {
this.channel.close(); // We can't wait as this may be called from an event loop. this.channel.close(); // We can't wait as this may be called from an event loop.
@@ -478,7 +619,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -481,7 +622,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
public void handleDisconnection() { public void handleDisconnection() {
if (this.channel != null && !this.channel.isOpen()) { if (this.channel != null && !this.channel.isOpen()) {
if (this.disconnectionHandled) { if (this.disconnectionHandled) {
@ -280,7 +280,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2
} else { } else {
this.disconnectionHandled = true; this.disconnectionHandled = true;
if (this.getDisconnectedReason() != null) { if (this.getDisconnectedReason() != null) {
@@ -486,7 +627,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -489,7 +630,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
} else if (this.getPacketListener() != null) { } else if (this.getPacketListener() != null) {
this.getPacketListener().onDisconnect(Component.translatable("multiplayer.disconnect.generic")); this.getPacketListener().onDisconnect(Component.translatable("multiplayer.disconnect.generic"));
} }
@ -289,7 +289,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2
// Paper start - Add PlayerConnectionCloseEvent // Paper start - Add PlayerConnectionCloseEvent
final PacketListener packetListener = this.getPacketListener(); final PacketListener packetListener = this.getPacketListener();
if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl) { if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl) {
@@ -526,6 +667,18 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -529,6 +670,18 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@Nullable @Nullable
final PacketSendListener listener; final PacketSendListener listener;

View File

@ -474,7 +474,7 @@ index 52eb3176437113f9a0ff85d10ce5c2415e1b5570..b54ddd0ba0b001fbcb1838a838ca4890
} }
} }
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 184f36a137ed5e5cd20797e131801bc29449cf5c..d3b5039adaa91fa254a582f030b33276c68fca0d 100644 index ca9a36e357e73b1b518ebb5c937314269655de32..59bb1d340e0be6f15a8c6ac21500cdd909c18a8b 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -64,13 +64,13 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -64,13 +64,13 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@ -494,7 +494,7 @@ index 184f36a137ed5e5cd20797e131801bc29449cf5c..d3b5039adaa91fa254a582f030b33276
}); });
private final PacketFlow receiving; private final PacketFlow receiving;
private final Queue<Connection.PacketHolder> queue = Queues.newConcurrentLinkedQueue(); private final Queue<Connection.PacketHolder> queue = Queues.newConcurrentLinkedQueue();
@@ -196,7 +196,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -199,7 +199,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
} }
} }

View File

@ -8,10 +8,10 @@ the world per tick, this attempts to reduce the impact that join floods
has on the server has on the server
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index d3b5039adaa91fa254a582f030b33276c68fca0d..e4c471ad111efb40a820670328b67ac28c79bff0 100644 index 59bb1d340e0be6f15a8c6ac21500cdd909c18a8b..ecc075d22b24f9e70cd3751c9ceea84b903020ae 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -440,14 +440,29 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -443,14 +443,29 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
} }
// Paper end // Paper end

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Add API for quit reason
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index e4c471ad111efb40a820670328b67ac28c79bff0..6ef3a08ea5223ee28dd175d66c6405efe5517993 100644 index ecc075d22b24f9e70cd3751c9ceea84b903020ae..90dd5a5c3ac94782483f99165bb3ddc85c179aae 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -173,12 +173,15 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -176,12 +176,15 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
this.handlingFault = true; this.handlingFault = true;
if (this.channel.isOpen()) { if (this.channel.isOpen()) {

View File

@ -122,10 +122,10 @@ index 0000000000000000000000000000000000000000..0d7e7db9e37ef0183c32b217bd944fb4
+ COMPRESSION_DISABLED + COMPRESSION_DISABLED
+} +}
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 6ef3a08ea5223ee28dd175d66c6405efe5517993..3cee24bfb1b3a21b0da1b57e161afd8009942272 100644 index 90dd5a5c3ac94782483f99165bb3ddc85c179aae..1404389f16cb6ed8bb1b2dad35e364b1428810a4 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -622,6 +622,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -625,6 +625,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
} else { } else {
this.channel.pipeline().addBefore("encoder", "compress", new CompressionEncoder(compressionThreshold)); this.channel.pipeline().addBefore("encoder", "compress", new CompressionEncoder(compressionThreshold));
} }
@ -133,7 +133,7 @@ index 6ef3a08ea5223ee28dd175d66c6405efe5517993..3cee24bfb1b3a21b0da1b57e161afd80
} else { } else {
if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder) { if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder) {
this.channel.pipeline().remove("decompress"); this.channel.pipeline().remove("decompress");
@@ -630,6 +631,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -633,6 +634,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
if (this.channel.pipeline().get("compress") instanceof CompressionEncoder) { if (this.channel.pipeline().get("compress") instanceof CompressionEncoder) {
this.channel.pipeline().remove("compress"); this.channel.pipeline().remove("compress");
} }

View File

@ -9,7 +9,7 @@ This patch will be used to optimise out flush calls in later
patches. patches.
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d41fc4bdf8 100644 index 1404389f16cb6ed8bb1b2dad35e364b1428810a4..d7dd0b806d8d8e3f04f165a2b29097a5c1bcd199 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -124,6 +124,39 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -124,6 +124,39 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@ -52,7 +52,7 @@ index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d4
public Connection(PacketFlow side) { public Connection(PacketFlow side) {
this.receiving = side; this.receiving = side;
} }
@@ -289,7 +322,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -292,7 +325,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
io.papermc.paper.util.MCUtil.isMainThread() && packet.isReady() && this.queue.isEmpty() && io.papermc.paper.util.MCUtil.isMainThread() && packet.isReady() && this.queue.isEmpty() &&
(packet.getExtraPackets() == null || packet.getExtraPackets().isEmpty()) (packet.getExtraPackets() == null || packet.getExtraPackets().isEmpty())
))) { ))) {
@ -61,7 +61,7 @@ index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d4
return; return;
} }
// write the packets to the queue, then flush - antixray hooks there already // write the packets to the queue, then flush - antixray hooks there already
@@ -313,6 +346,14 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -316,6 +349,14 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
} }
private void sendPacket(Packet<?> packet, @Nullable PacketSendListener callbacks) { private void sendPacket(Packet<?> packet, @Nullable PacketSendListener callbacks) {
@ -76,7 +76,7 @@ index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d4
ConnectionProtocol enumprotocol = ConnectionProtocol.getProtocolForPacket(packet); ConnectionProtocol enumprotocol = ConnectionProtocol.getProtocolForPacket(packet);
ConnectionProtocol enumprotocol1 = this.getCurrentProtocol(); ConnectionProtocol enumprotocol1 = this.getCurrentProtocol();
@@ -327,16 +368,21 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -330,16 +371,21 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
} }
if (this.channel.eventLoop().inEventLoop()) { if (this.channel.eventLoop().inEventLoop()) {
@ -100,7 +100,7 @@ index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d4
if (packetState != currentState) { if (packetState != currentState) {
this.setProtocol(packetState); this.setProtocol(packetState);
} }
@@ -350,7 +396,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -353,7 +399,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
try { try {
// Paper end // Paper end
@ -109,7 +109,7 @@ index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d4
if (callbacks != null) { if (callbacks != null) {
channelfuture.addListener((future) -> { channelfuture.addListener((future) -> {
@@ -406,6 +452,10 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -409,6 +455,10 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
private boolean processQueue() { private boolean processQueue() {
try { // Paper - add pending task queue try { // Paper - add pending task queue
if (this.queue.isEmpty()) return true; if (this.queue.isEmpty()) return true;
@ -120,7 +120,7 @@ index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d4
// If we are on main, we are safe here in that nothing else should be processing queue off main anymore // If we are on main, we are safe here in that nothing else should be processing queue off main anymore
// But if we are not on main due to login/status, the parent is synchronized on packetQueue // But if we are not on main due to login/status, the parent is synchronized on packetQueue
java.util.Iterator<PacketHolder> iterator = this.queue.iterator(); java.util.Iterator<PacketHolder> iterator = this.queue.iterator();
@@ -413,7 +463,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -416,7 +466,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
PacketHolder queued = iterator.next(); // poll -> peek PacketHolder queued = iterator.next(); // poll -> peek
// Fix NPE (Spigot bug caused by handleDisconnection()) // Fix NPE (Spigot bug caused by handleDisconnection())
@ -129,7 +129,7 @@ index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d4
return true; return true;
} }
@@ -425,11 +475,17 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -428,11 +478,17 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
Packet<?> packet = queued.packet; Packet<?> packet = queued.packet;
if (!packet.isReady()) { if (!packet.isReady()) {

View File

@ -7,10 +7,10 @@ Subject: [PATCH] Detail more information in watchdog dumps
- Dump player name, player uuid, position, and world for packet handling - Dump player name, player uuid, position, and world for packet handling
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index e2f28c9c51f30b0e2b22055bb10899d41fc4bdf8..2ff278d085b25f40c1bdf0cc0cb564fb441ae1cd 100644 index d7dd0b806d8d8e3f04f165a2b29097a5c1bcd199..b967c24e9ace2b6539e94bcc63b69e0c934a72be 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -519,7 +519,13 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -522,7 +522,13 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
if (!(this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginPacketListener) if (!(this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginPacketListener)
|| loginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT || loginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT
|| Connection.joinAttemptsThisTick++ < MAX_PER_TICK) { || Connection.joinAttemptsThisTick++ < MAX_PER_TICK) {

View File

@ -24,7 +24,7 @@ and an action can be defined: DROP or KICK
If interval or rate are less-than 0, the limit is ignored If interval or rate are less-than 0, the limit is ignored
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 2ff278d085b25f40c1bdf0cc0cb564fb441ae1cd..f7ab5db5f5301d6efee1141f7725548eded2ed74 100644 index b967c24e9ace2b6539e94bcc63b69e0c934a72be..ed27a0eb28b39f045064432107a86efc3b5927cd 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -156,6 +156,22 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -156,6 +156,22 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@ -50,7 +50,7 @@ index 2ff278d085b25f40c1bdf0cc0cb564fb441ae1cd..f7ab5db5f5301d6efee1141f7725548e
public Connection(PacketFlow side) { public Connection(PacketFlow side) {
this.receiving = side; this.receiving = side;
@@ -237,6 +253,45 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -240,6 +256,45 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
protected void channelRead0(ChannelHandlerContext channelhandlercontext, Packet<?> packet) { protected void channelRead0(ChannelHandlerContext channelhandlercontext, Packet<?> packet) {
if (this.channel.isOpen()) { if (this.channel.isOpen()) {

View File

@ -20,7 +20,7 @@ up on this optimisation before he came along.
Locally this patch drops the entity tracker tick by a full 1.5x. Locally this patch drops the entity tracker tick by a full 1.5x.
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index f7ab5db5f5301d6efee1141f7725548eded2ed74..398af26a2408916fda3e71e887bbb73994727bc7 100644 index ed27a0eb28b39f045064432107a86efc3b5927cd..9b46c1068b7b52f735423fc255ae6e949dd5cb0b 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -48,6 +48,8 @@ import org.slf4j.Logger; @@ -48,6 +48,8 @@ import org.slf4j.Logger;
@ -32,7 +32,7 @@ index f7ab5db5f5301d6efee1141f7725548eded2ed74..398af26a2408916fda3e71e887bbb739
public class Connection extends SimpleChannelInboundHandler<Packet<?>> { public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
private static final float AVERAGE_PACKETS_SMOOTHING = 0.75F; private static final float AVERAGE_PACKETS_SMOOTHING = 0.75F;
@@ -425,9 +427,19 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -428,9 +430,19 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
if (this.channel.eventLoop().inEventLoop()) { if (this.channel.eventLoop().inEventLoop()) {
this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1, flush); // Paper this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1, flush); // Paper
} else { } else {

View File

@ -268,10 +268,10 @@ index 792883afe53d2b7989c25a81c2f9a639d5e21d20..c04379ca8a4db0f4de46ad2b3b338431
return this.threshold; return this.threshold;
} }
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 398af26a2408916fda3e71e887bbb73994727bc7..fa1d325034dafdb9f1da546a6f9c5e88d2b67749 100644 index 9b46c1068b7b52f735423fc255ae6e949dd5cb0b..f9e10bf048929886db3c414038d2c7e9f84226a6 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -707,11 +707,28 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -710,11 +710,28 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
return networkmanager; return networkmanager;
} }
@ -304,7 +304,7 @@ index 398af26a2408916fda3e71e887bbb73994727bc7..fa1d325034dafdb9f1da546a6f9c5e88
public boolean isEncrypted() { public boolean isEncrypted() {
return this.encrypted; return this.encrypted;
@@ -740,16 +757,17 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -743,16 +760,17 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
public void setupCompression(int compressionThreshold, boolean rejectsBadPackets) { public void setupCompression(int compressionThreshold, boolean rejectsBadPackets) {
if (compressionThreshold >= 0) { if (compressionThreshold >= 0) {
@ -341,7 +341,7 @@ index 838244e3680ea6020701e10bafbde7f52976eaa1..e5e2f763d9b4b955df79ea0c4c79565b
protected void initChannel(Channel channel) { protected void initChannel(Channel channel) {
try { try {
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 5ae5c35ee4d058bde6726797abb1472ee0516256..471e21f9e1f3ad6302e647d26a44b521fece223b 100644 index b026c003e1fc02a9ea426f3126acb788fc09a874..595779cfd0ee1c405d7936f00a7cae1706125e7f 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -265,12 +265,14 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @@ -265,12 +265,14 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,