Ignore AsyncCatcher setting for Command Dispatch, always force sync

Plugins were abusing this to dispatch commands async anyways.

We will no longer check that flag, and force all commands to be ran sync.

Use a different boolean for allowing things go to through on shutdown/restart instead.

Resolves #1004
Resolves #1005
This commit is contained in:
Aikar 2018-02-15 00:34:58 -05:00
parent 84b0287c54
commit a64aa09862
No known key found for this signature in database
GPG Key ID: 401ADFC9891FAAFE
3 changed files with 50 additions and 14 deletions

View File

@ -1,4 +1,4 @@
From 682aec6f3018c0732d241afabcda0b4fbc514d6f Mon Sep 17 00:00:00 2001
From 09e8ebb6054e3f37de7d78ab784147cbf62985d4 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 01:17:12 -0600
Subject: [PATCH] Ensure commands are not ran async
@ -14,7 +14,7 @@ big slowdown in execution but throwing an exception at same time to raise awaren
that it is happening so that plugin authors can fix their code to stop executing commands async.
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index da25a8be..5348c0cb 100644
index da25a8bea..48379f414 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1311,6 +1311,29 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@ -22,7 +22,7 @@ index da25a8be..5348c0cb 100644
if (!async && s.startsWith("/")) {
+ // Paper Start
+ if (org.spigotmc.AsyncCatcher.enabled && !org.bukkit.Bukkit.isPrimaryThread()) {
+ if (!org.spigotmc.AsyncCatcher.shuttingDown && !org.bukkit.Bukkit.isPrimaryThread()) {
+ final String fCommandLine = s;
+ MinecraftServer.LOGGER.log(org.apache.logging.log4j.Level.ERROR, "Command Dispatched Async: " + fCommandLine);
+ MinecraftServer.LOGGER.log(org.apache.logging.log4j.Level.ERROR, "Please notify author of plugin causing this execution to fix this bug! see: http://bit.ly/1oSiM6C", new Throwable());
@ -48,7 +48,7 @@ index da25a8be..5348c0cb 100644
} else if (this.player.getChatFlags() == EntityHuman.EnumChatVisibility.SYSTEM) {
// Do nothing, this is coming from a plugin
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index bfddd168..082957d3 100644
index bfddd1685..462ad1024 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -645,6 +645,29 @@ public final class CraftServer implements Server {
@ -56,7 +56,7 @@ index bfddd168..082957d3 100644
Validate.notNull(commandLine, "CommandLine cannot be null");
+ // Paper Start
+ if (org.spigotmc.AsyncCatcher.enabled && !Bukkit.isPrimaryThread()) {
+ if (!org.spigotmc.AsyncCatcher.shuttingDown && !Bukkit.isPrimaryThread()) {
+ final CommandSender fSender = sender;
+ final String fCommandLine = commandLine;
+ Bukkit.getLogger().log(Level.SEVERE, "Command Dispatched Async: " + commandLine);
@ -81,6 +81,42 @@ index bfddd168..082957d3 100644
if (commandMap.dispatch(sender, commandLine)) {
return true;
}
--
2.14.3
diff --git a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
index a0cdd2317..984df4083 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
@@ -14,6 +14,7 @@ public class ServerShutdownThread extends Thread {
public void run() {
try {
org.spigotmc.AsyncCatcher.enabled = false; // Spigot
+ org.spigotmc.AsyncCatcher.shuttingDown = true; // Paper
server.stop();
} catch (ExceptionWorldConflict ex) {
ex.printStackTrace();
diff --git a/src/main/java/org/spigotmc/AsyncCatcher.java b/src/main/java/org/spigotmc/AsyncCatcher.java
index 4b3aa85c9..e44c23016 100644
--- a/src/main/java/org/spigotmc/AsyncCatcher.java
+++ b/src/main/java/org/spigotmc/AsyncCatcher.java
@@ -6,6 +6,7 @@ public class AsyncCatcher
{
public static boolean enabled = true;
+ public static boolean shuttingDown = false; // Paper
public static void catchOp(String reason)
{
diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java
index 49768734d..947c43a5d 100644
--- a/src/main/java/org/spigotmc/RestartCommand.java
+++ b/src/main/java/org/spigotmc/RestartCommand.java
@@ -43,6 +43,7 @@ public class RestartCommand extends Command
public static void restart(final File script)
{
AsyncCatcher.enabled = false; // Disable async catcher incase it interferes with us
+ org.spigotmc.AsyncCatcher.shuttingDown = true; // Paper
try
{
if ( script.isFile() )
--
2.16.1

View File

@ -1,4 +1,4 @@
From 1dfb9d1c54af2782c982eb047eb68c11c619beec Mon Sep 17 00:00:00 2001
From ff7f3e57d17fc5b364048efaa4541921c101d43c Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Fri, 12 May 2017 23:34:11 -0500
Subject: [PATCH] Properly handle async calls to restart the server
@ -107,11 +107,11 @@ index 4080ed26c..ff01bbff5 100644
// CraftBukkit start
public void sendMessage(IChatBaseComponent[] iChatBaseComponents) {
diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java
index 49768734d..d51636c8e 100644
index 947c43a5d..f15fd9f37 100644
--- a/src/main/java/org/spigotmc/RestartCommand.java
+++ b/src/main/java/org/spigotmc/RestartCommand.java
@@ -45,88 +45,123 @@ public class RestartCommand extends Command
AsyncCatcher.enabled = false; // Disable async catcher incase it interferes with us
@@ -46,88 +46,123 @@ public class RestartCommand extends Command
org.spigotmc.AsyncCatcher.shuttingDown = true; // Paper
try
{
- if ( script.isFile() )

View File

@ -1,4 +1,4 @@
From 6d092c14a6e1204d23a92dbc3747487fd9620aea Mon Sep 17 00:00:00 2001
From f300c987bf978cd5a1a6466e4f846a704a692809 Mon Sep 17 00:00:00 2001
From: Minecrell <dev@minecrell.net>
Date: Fri, 9 Jun 2017 19:03:43 +0200
Subject: [PATCH] Use TerminalConsoleAppender for console improvements
@ -304,7 +304,7 @@ index ff01bbff5..311c0b86f 100644
this.k = new GameProfileBanList(PlayerList.a);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 50341ae6e..fa831dc8f 100644
index 27c6caddc..539f492e0 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -128,7 +128,6 @@ import io.netty.buffer.ByteBuf;
@ -530,10 +530,10 @@ index 33e8ea02c..1e3aae3b8 100644
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
index a0cdd2317..0a1812883 100644
index 984df4083..bbb5a84f3 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
@@ -19,7 +19,7 @@ public class ServerShutdownThread extends Thread {
@@ -20,7 +20,7 @@ public class ServerShutdownThread extends Thread {
ex.printStackTrace();
} finally {
try {