From 7b52db5f612ff0aca575760e79fd24be96b10fdd 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/0004-Paper-config-files.patch | 10 +++---- .../server/0468-Buffer-joins-to-world.patch | 28 +++++++++++-------- ...l-more-information-in-watchdog-dumps.patch | 18 ++++++------ .../0896-Configurable-chat-thread-limit.patch | 4 +-- 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/patches/server/0004-Paper-config-files.patch b/patches/server/0004-Paper-config-files.patch index ccd9b9a7fb..9ab5c1e13c 100644 --- a/patches/server/0004-Paper-config-files.patch +++ b/patches/server/0004-Paper-config-files.patch @@ -440,7 +440,7 @@ index 0000000000000000000000000000000000000000..c2dca89291361d60cbf160cab77749cb +} diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java new file mode 100644 -index 0000000000000000000000000000000000000000..56a5e20c47e2ee2169611e20969803bcfd75f88f +index 0000000000000000000000000000000000000000..52b02cb1f02d1c65b840f38cfc8baee500aa2259 --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java @@ -0,0 +1,277 @@ @@ -709,7 +709,7 @@ index 0000000000000000000000000000000000000000..56a5e20c47e2ee2169611e20969803bc + // TODO: FILL + } + } -+ public int maxJoinsPerTick = 3; ++ public int maxJoinsPerTick = 5; + public boolean fixEntityPositionDesync = true; + public boolean loadPermissionsYmlBeforePlugins = true; + @Constraints.Min(4) @@ -4423,7 +4423,7 @@ index 7c35fb22df0bca2c2ca885a872ee42d6073d852f..26fc8127024d7b81ffe5c1c81b8ef8a6 } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 5efdc61dfa1a8d74fead69e76425a45cd97783d5..caae5d862461c7dcf5fa9bf36e51276925668945 100644 +index 16a2efb7dcbcafca867fd75972a0bd80937b95a8..ae219be37c5fcec3dd3f8b08819551003e66d351 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -230,7 +230,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -4464,7 +4464,7 @@ index bf6f50cfe5225804ae2cab4f50bcc7ee2ddfe36e..ca5cbd7c43d7e263f76d8719a259514c this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 030b852353f831a64a9466a2cfdfb0cd76243d8d..64db49f699ebd0baf1cce79c1ef20c5b7a83f2b3 100644 +index 9afc0881f6891ef2696b6f2b37c0826f3beb0666..8873bf84c71c48297a360df9c99e511fa0af5b40 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -885,6 +885,7 @@ public final class CraftServer implements Server { @@ -4476,7 +4476,7 @@ index 030b852353f831a64a9466a2cfdfb0cd76243d8d..64db49f699ebd0baf1cce79c1ef20c5b world.serverLevelData.setDifficulty(config.difficulty); world.setSpawnSettings(config.spawnMonsters, config.spawnAnimals); diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index 68aafbe2ff05ad2c48b8f3ed23d779680bca574a..a857f9e20d2fe0f495df884e81489e89a64bea54 100644 +index 16c38195c3e4f5550122df0d65fcce8ca3a83822..1d4f6e7fcfaaee40b06f74d250d04f7a36b6458b 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -131,6 +131,19 @@ public class Main { diff --git a/patches/server/0468-Buffer-joins-to-world.patch b/patches/server/0468-Buffer-joins-to-world.patch index 325446a834..1a61d68572 100644 --- a/patches/server/0468-Buffer-joins-to-world.patch +++ b/patches/server/0468-Buffer-joins-to-world.patch @@ -8,10 +8,10 @@ the world per tick, this attempts to reduce the impact that join floods has on the server diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index d032f8d011b94f396c9d5606f42a8c331db62740..4487b4329cf09a6538e272c44207dda492ceb099 100644 +index d032f8d011b94f396c9d5606f42a8c331db62740..501d17ba798c5928279a93c45de3eb6e8a3f99d6 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -433,8 +433,23 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -433,14 +433,29 @@ public class Connection extends SimpleChannelInboundHandler> { } // Paper end @@ -21,17 +21,23 @@ index d032f8d011b94f396c9d5606f42a8c331db62740..4487b4329cf09a6538e272c44207dda4 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/0708-Detail-more-information-in-watchdog-dumps.patch b/patches/server/0708-Detail-more-information-in-watchdog-dumps.patch index 30398718ce..0888837722 100644 --- a/patches/server/0708-Detail-more-information-in-watchdog-dumps.patch +++ b/patches/server/0708-Detail-more-information-in-watchdog-dumps.patch @@ -7,25 +7,23 @@ Subject: [PATCH] Detail more information in watchdog dumps - 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 -index b996b5c6a8dccd122fbb5d04f446927ae788bad5..8ba85f8b36b06ce5047b2587018a49dc50207866 100644 +index 3355d0d75675e2f9a62c4681871ba0f403073286..46153b8e5823959e17621bbebd414d8998b77fb5 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -512,9 +512,15 @@ public class Connection extends SimpleChannelInboundHandler> { - PacketListener packetlistener = this.packetListener; - - if (packetlistener instanceof TickablePacketListener) { +@@ -512,7 +512,13 @@ public class Connection extends SimpleChannelInboundHandler> { + 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 acfa1907bfc9c29d261cfccc00d65bad9ad1a002..d6f3869f5725c7f081efb7f486f74dbb99d4d005 100644 --- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java diff --git a/patches/server/0896-Configurable-chat-thread-limit.patch b/patches/server/0896-Configurable-chat-thread-limit.patch index 1bb08ba4e5..e23447bc3e 100644 --- a/patches/server/0896-Configurable-chat-thread-limit.patch +++ b/patches/server/0896-Configurable-chat-thread-limit.patch @@ -22,7 +22,7 @@ is actually processed, this is honestly really just exposed for the misnomers or who just wanna ensure that this won't grow over a specific size if chat gets stupidly active diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -index 56a5e20c47e2ee2169611e20969803bcfd75f88f..63ec2ebb71aa0e0dbb64bbce7cd3c9494e9ce2e7 100644 +index 52b02cb1f02d1c65b840f38cfc8baee500aa2259..8d442c5a498ecf288a0cc0c54889c6e2fda849ce 100644 --- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java @@ -254,13 +254,26 @@ public class GlobalConfiguration extends ConfigurationPart { @@ -52,4 +52,4 @@ index 56a5e20c47e2ee2169611e20969803bcfd75f88f..63ec2ebb71aa0e0dbb64bbce7cd3c949 + executor.setMaximumPoolSize(_chatExecutorMaxSize); } } - public int maxJoinsPerTick = 3; + public int maxJoinsPerTick = 5;