From 583c8afcd829ef2c55d13e5055ffcede0667f414 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 21 Dec 2022 22:55:42 +0100 Subject: [PATCH] Fix buffer-joins-to-world patch --- patches/server/Buffer-joins-to-world.patch | 24 ++++++++++++------- .../Configurable-chat-thread-limit.patch | 2 +- ...l-more-information-in-watchdog-dumps.patch | 14 +++++------ patches/server/Paper-config-files.patch | 2 +- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/patches/server/Buffer-joins-to-world.patch b/patches/server/Buffer-joins-to-world.patch index 546cac47b8..6e51274d45 100644 --- a/patches/server/Buffer-joins-to-world.patch +++ b/patches/server/Buffer-joins-to-world.patch @@ -21,17 +21,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void tick() { this.flushQueue(); + // Paper start -+ if (currTick != net.minecraft.server.MinecraftServer.currentTick) { -+ currTick = net.minecraft.server.MinecraftServer.currentTick; -+ joinAttemptsThisTick = 0; ++ if (Connection.currTick != net.minecraft.server.MinecraftServer.currentTick) { ++ Connection.currTick = net.minecraft.server.MinecraftServer.currentTick; ++ Connection.joinAttemptsThisTick = 0; + } + // Paper end -+ if (this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl) { -+ if ( ((net.minecraft.server.network.ServerLoginPacketListenerImpl) this.packetListener).state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT // Paper -+ || (joinAttemptsThisTick++ < MAX_PER_TICK)) { // Paper - limit the number of joins which can be processed each tick -+ ((net.minecraft.server.network.ServerLoginPacketListenerImpl) this.packetListener).tick(); -+ } // Paper -+ } PacketListener packetlistener = this.packetListener; if (packetlistener instanceof TickablePacketListener) { + TickablePacketListener tickablepacketlistener = (TickablePacketListener) packetlistener; + ++ // Paper start - limit the number of joins which can be processed each tick ++ if (!(this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginPacketListener) ++ || loginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT ++ || Connection.joinAttemptsThisTick++ < MAX_PER_TICK) { + tickablepacketlistener.tick(); ++ } ++ // Paper end + } + + if (!this.isConnected() && !this.disconnectionHandled) { diff --git a/patches/server/Configurable-chat-thread-limit.patch b/patches/server/Configurable-chat-thread-limit.patch index 74ae2b6a7d..b3752fce97 100644 --- a/patches/server/Configurable-chat-thread-limit.patch +++ b/patches/server/Configurable-chat-thread-limit.patch @@ -52,4 +52,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + executor.setMaximumPoolSize(_chatExecutorMaxSize); } } - public int maxJoinsPerTick = 3; + public int maxJoinsPerTick = 5; diff --git a/patches/server/Detail-more-information-in-watchdog-dumps.patch b/patches/server/Detail-more-information-in-watchdog-dumps.patch index fc4a8c8208..9f01bbda4b 100644 --- a/patches/server/Detail-more-information-in-watchdog-dumps.patch +++ b/patches/server/Detail-more-information-in-watchdog-dumps.patch @@ -11,21 +11,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler> { - PacketListener packetlistener = this.packetListener; - - if (packetlistener instanceof TickablePacketListener) { + if (!(this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginPacketListener) + || loginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT + || Connection.joinAttemptsThisTick++ < MAX_PER_TICK) { + // Paper start - detailed watchdog information + net.minecraft.network.protocol.PacketUtils.packetProcessing.push(this.packetListener); + try { // Paper end - detailed watchdog information - TickablePacketListener tickablepacketlistener = (TickablePacketListener) packetlistener; - tickablepacketlistener.tick(); + } finally { // Paper start - detailed watchdog information + net.minecraft.network.protocol.PacketUtils.packetProcessing.pop(); -+ } // Paper start - detailed watchdog information ++ } // Paper end - detailed watchdog information + } + // Paper end } - - if (!this.isConnected() && !this.disconnectionHandled) { diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java diff --git a/patches/server/Paper-config-files.patch b/patches/server/Paper-config-files.patch index bdd13e9be2..02ec8ca2b8 100644 --- a/patches/server/Paper-config-files.patch +++ b/patches/server/Paper-config-files.patch @@ -709,7 +709,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // TODO: FILL + } + } -+ public int maxJoinsPerTick = 3; ++ public int maxJoinsPerTick = 5; + public boolean fixEntityPositionDesync = true; + public boolean loadPermissionsYmlBeforePlugins = true; + @Constraints.Min(4)