aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0348-Fix-CraftServer-isPrimaryThread-and-MinecraftServer-.patch
blob: f1c6a6686989ebbd105478fcd01b835cc60547ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Mon, 13 May 2019 21:10:59 -0700
Subject: [PATCH] Fix CraftServer#isPrimaryThread and MinecraftServer
 isMainThread

md_5 changed it so he could shut down the server asynchronously
from watchdog, although we have patches that prevent that type
of behavior for this exact reason.

md_5 also placed code in PlayerConnectionUtils that would have
solved https://bugs.mojang.com/browse/MC-142590, making the change
to MinecraftServer#isMainThread irrelevant.
By reverting his change to MinecraftServer#isMainThread packet
handling that should have been handled synchronously will be handled
synchronously when the server gets shut down.

diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index fa7935cccb450ae5f782fec5ebe27275fe6dd510..5a5e097b131500d7cb9f61ea0f96f9006fabb941 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -2192,7 +2192,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
     // CraftBukkit start
     @Override
     public boolean isMainThread() {
-        return super.isMainThread() || this.isStopped(); // CraftBukkit - MC-142590
+        return super.isMainThread() /*|| this.isStopped()*/; // CraftBukkit - MC-142590 // Paper - causes issues elsewhere
     }
 
     public boolean isDebugging() {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index b46fe9254a2dce30db9733281e4d36daa9d08e01..08327d80cca5e3fea513260c403c1839e06219a3 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1838,7 +1838,7 @@ public final class CraftServer implements Server {
 
     @Override
     public boolean isPrimaryThread() {
-        return Thread.currentThread().equals(console.serverThread) || console.hasStopped() || !org.spigotmc.AsyncCatcher.enabled; // All bets are off if we have shut down (e.g. due to watchdog)
+        return Thread.currentThread().equals(console.serverThread); // Paper - Fix issues with detecting main thread properly
     }
 
     // Paper start