mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-07 03:10:50 +01:00
b8edb0e130
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 6b34da8f SPIGOT-7467: Add getAddress to RemoteConsoleCommandSender CraftBukkit Changes: db4ba2897 SPIGOT-7467: Add getAddress to RemoteConsoleCommandSender 4f7ff4dec PR-1246: Add missing AbstractTestingBase to tests which need them f70a7b68d SPIGOT-7465, MC-264979: Fresh installations print NoSuchFileException for server.properties 8ef7afef6 PR-1240: Call BlockGrowEvent for vines that are growing on additional sides of an existing vine block Spigot Changes: d2eba2c8 Rebuild patches
60 lines
2.8 KiB
Diff
60 lines
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sun, 10 May 2020 22:16:17 -0400
|
|
Subject: [PATCH] Wait for Async Tasks during shutdown
|
|
|
|
Server.reload() had this logic to give time for tasks to shutdown,
|
|
however shutdown did not...
|
|
|
|
Adds a 5 second grace period for any async tasks to finish and warns
|
|
if any are still running after that delay just as reload does.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 8b1a92c1a0e9505ebc11de0e6b54b48343ef8e60..ccf238c12c416e2aa7ee83a14bbbb96f5b2f8b51 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -927,6 +927,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
// CraftBukkit start
|
|
if (this.server != null) {
|
|
this.server.disablePlugins();
|
|
+ this.server.waitForAsyncTasksShutdown(); // Paper
|
|
}
|
|
// CraftBukkit end
|
|
if (this.getConnection() != null) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 900e38b7ac712cdbc64ec580ee7f2e09e1ceccc3..6134dfb1b64c8ab88053f62aea5341ead2563db7 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -1036,6 +1036,31 @@ public final class CraftServer implements Server {
|
|
org.spigotmc.WatchdogThread.hasStarted = true; // Paper - Disable watchdog early timeout on reload
|
|
}
|
|
|
|
+ // Paper start
|
|
+ public void waitForAsyncTasksShutdown() {
|
|
+ int pollCount = 0;
|
|
+
|
|
+ // Wait for at most 5 seconds for plugins to close their threads
|
|
+ while (pollCount < 10*5 && getScheduler().getActiveWorkers().size() > 0) {
|
|
+ try {
|
|
+ Thread.sleep(100);
|
|
+ } catch (InterruptedException e) {}
|
|
+ pollCount++;
|
|
+ }
|
|
+
|
|
+ List<BukkitWorker> overdueWorkers = getScheduler().getActiveWorkers();
|
|
+ for (BukkitWorker worker : overdueWorkers) {
|
|
+ Plugin plugin = worker.getOwner();
|
|
+ getLogger().log(Level.SEVERE, String.format(
|
|
+ "Nag author(s): '%s' of '%s' about the following: %s",
|
|
+ plugin.getPluginMeta().getAuthors(),
|
|
+ plugin.getPluginMeta().getDisplayName(),
|
|
+ "This plugin is not properly shutting down its async tasks when it is being shut down. This task may throw errors during the final shutdown logs and might not complete before process dies."
|
|
+ ));
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@Override
|
|
public void reloadData() {
|
|
ReloadCommand.reload(console);
|