From 309133e2e14502e3734e5be8aec4068549abf3f8 Mon Sep 17 00:00:00 2001 From: Denery <63610262+maestro-denery@users.noreply.github.com> Date: Sun, 27 Nov 2022 20:20:31 +0300 Subject: [PATCH] Fix preemptive connection dropping during shutdown process (#8546) --- LICENSE.md | 1 + .../0949-Fix-player-kick-on-shutdown.patch | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 patches/server/0949-Fix-player-kick-on-shutdown.patch diff --git a/LICENSE.md b/LICENSE.md index ae592616df..6a10bab905 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -53,4 +53,5 @@ Nick Hensel vytskalt TheFruxz Kieran Wallbanks +Denery ``` diff --git a/patches/server/0949-Fix-player-kick-on-shutdown.patch b/patches/server/0949-Fix-player-kick-on-shutdown.patch new file mode 100644 index 0000000000..65fe95e7f6 --- /dev/null +++ b/patches/server/0949-Fix-player-kick-on-shutdown.patch @@ -0,0 +1,23 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Denery +Date: Sun, 6 Nov 2022 02:02:46 +0300 +Subject: [PATCH] Fix player kick on shutdown + +Fix preemptive player kick on a server shutdown. +If you update minecraft version / upstream and something is changed in this method make sure that a server doesn't disconnect a player preemptively, +also check if all packets are ignored during the shutdown process. +See net.minecraft.network.Connection#channelRead0(ChannelHandlerContext, Packet) and net.minecraft.util.thread.BlockableEventLoop#executeIfPossible(Runnable) + +diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java +index 8bc0cb9ad5bb4e76d962ff54305e2c08e279a17b..edefab4e22ee7217e17eb036165ce58788d4c782 100644 +--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java ++++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java +@@ -41,7 +41,7 @@ public class PacketUtils { + + public static void ensureRunningOnSameThread(Packet packet, T listener, BlockableEventLoop engine) throws RunningOnDifferentThreadException { + if (!engine.isSameThread()) { +- engine.executeIfPossible(() -> { ++ engine.execute(() -> { // Paper - Fix preemptive player kick on a server shutdown. + packetProcessing.push(listener); // Paper - detailed watchdog information + try { // Paper - detailed watchdog information + if (MinecraftServer.getServer().hasStopped() || (listener instanceof ServerGamePacketListenerImpl && ((ServerGamePacketListenerImpl) listener).processedDisconnect)) return; // CraftBukkit, MC-142590