mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 10:20:53 +01:00
526795bacd
* Update patches to handle vineflower decompiler * update patches again to handle inlined simple lambdas * update vf again and re-apply/rebuild patches * update patches after removal of verify-merges flag * fix compile issue * remove maven local * fix some issues * address more issues * fix collision patch * use paperweight release * more fixes * update fineflower and fix patches again * add missing comment descriptor --------- Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
60 lines
2.9 KiB
Diff
60 lines
2.9 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 f4e9929c956585a9305c2b40a995ec4fff08e7e4..af68110105a9a3ec0ebd31ea9733af8dfed1037b 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -931,6 +931,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
// CraftBukkit start
|
|
if (this.server != null) {
|
|
this.server.disablePlugins();
|
|
+ this.server.waitForAsyncTasksShutdown(); // Paper - Wait for Async Tasks during shutdown
|
|
}
|
|
// CraftBukkit end
|
|
this.getConnection().stop();
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 12b76fd9d3d5e8dcca31d7e82f6956e13447ff64..a5c84867708385ae78951872410914835ab3e7e5 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -1028,6 +1028,31 @@ public final class CraftServer implements Server {
|
|
org.spigotmc.WatchdogThread.hasStarted = true; // Paper - Disable watchdog early timeout on reload
|
|
}
|
|
|
|
+ // Paper start - Wait for Async Tasks during shutdown
|
|
+ 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 - Wait for Async Tasks during shutdown
|
|
+
|
|
@Override
|
|
public void reloadData() {
|
|
ReloadCommand.reload(this.console);
|