Update watchdog patches
This commit is contained in:
@@ -5,7 +5,7 @@ Subject: [PATCH] Anti-Xray
|
||||
|
||||
|
||||
diff --git a/io/papermc/paper/FeatureHooks.java b/io/papermc/paper/FeatureHooks.java
|
||||
index aad9d9687dffb872a12ba0ba39d674895b7474e7..764daee7cd619c56314bcea9a4c35702afcb262d 100644
|
||||
index 0eba4fce940b90e67f3746480c040178ba9f5525..3bdbd3d566dee767204d898e0bb4f82f0060d9ca 100644
|
||||
--- a/io/papermc/paper/FeatureHooks.java
|
||||
+++ b/io/papermc/paper/FeatureHooks.java
|
||||
@@ -7,6 +7,7 @@ import it.unimi.dsi.fastutil.longs.LongSets;
|
||||
@@ -16,7 +16,7 @@ index aad9d9687dffb872a12ba0ba39d674895b7474e7..764daee7cd619c56314bcea9a4c35702
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -35,20 +36,25 @@ public final class FeatureHooks {
|
||||
@@ -36,20 +37,25 @@ public final class FeatureHooks {
|
||||
}
|
||||
|
||||
public static LevelChunkSection createSection(final Registry<Biome> biomeRegistry, final Level level, final ChunkPos chunkPos, final int chunkSection) {
|
||||
@@ -46,13 +46,6 @@ index aad9d9687dffb872a12ba0ba39d674895b7474e7..764daee7cd619c56314bcea9a4c35702
|
||||
}
|
||||
|
||||
public static Set<Long> getSentChunkKeys(final ServerPlayer player) {
|
||||
@@ -74,4 +80,4 @@ public final class FeatureHooks {
|
||||
public static boolean isSpiderCollidingWithWorldBorder(final Spider spider) {
|
||||
return true; // ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.isCollidingWithBorder(spider.level().getWorldBorder(), spider.getBoundingBox().inflate(ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_EPSILON))
|
||||
}
|
||||
-}
|
||||
\ No newline at end of file
|
||||
+}
|
||||
diff --git a/net/minecraft/network/protocol/game/ClientboundChunksBiomesPacket.java b/net/minecraft/network/protocol/game/ClientboundChunksBiomesPacket.java
|
||||
index d4872b7f4e9591b3b1c67406312905851303f521..cb41460e94161675e2ab43f4b1b5286ee38e2e13 100644
|
||||
--- a/net/minecraft/network/protocol/game/ClientboundChunksBiomesPacket.java
|
||||
|
||||
@@ -30621,10 +30621,10 @@ index 1110ca4075a1bbaa46b66686435dab91b275c945..c2218630c3074c8b3f82364e37503b12
|
||||
return structureTemplate.save(new CompoundTag());
|
||||
}
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index d450d4af96716caff4b29a84d1d83ec4010854f0..646c2f2b617ed706021c83c9fc4492860dfdd4e9 100644
|
||||
index 7b233bd4c5c373fe38585e0f8d3e6367dd357741..fd6fdb6d7e15633bd01d4f930ee3b15c0dd2ca06 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -301,6 +301,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -303,6 +303,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
private final Set<String> pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping
|
||||
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) {
|
||||
|
||||
@@ -8,10 +8,10 @@ Areas affected by lag comepnsation:
|
||||
- Eating food items
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..8aa9ae2925ad44d57a27be3e520fcf20e30237d6 100644
|
||||
index fd6fdb6d7e15633bd01d4f930ee3b15c0dd2ca06..22dc6bec58702762e4a31415f9aed2df2b3ad0d6 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -299,6 +299,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -301,6 +301,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files
|
||||
public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
|
||||
private final Set<String> pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping
|
||||
@@ -19,7 +19,7 @@ index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..8aa9ae2925ad44d57a27be3e520fcf20
|
||||
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) {
|
||||
ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system
|
||||
@@ -1564,6 +1565,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1566,6 +1567,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
for (ServerLevel serverLevel : this.getAllLevels()) {
|
||||
serverLevel.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
|
||||
serverLevel.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- /dev/null
|
||||
+++ b/io/papermc/paper/FeatureHooks.java
|
||||
@@ -1,0 +_,77 @@
|
||||
@@ -1,0 +_,84 @@
|
||||
+package io.papermc.paper;
|
||||
+
|
||||
+import io.papermc.paper.command.PaperSubcommand;
|
||||
@@ -16,6 +16,7 @@
|
||||
+import net.minecraft.core.Registry;
|
||||
+import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import net.minecraft.world.entity.Entity;
|
||||
+import net.minecraft.world.entity.monster.Spider;
|
||||
+import net.minecraft.world.level.ChunkPos;
|
||||
+import net.minecraft.world.level.Level;
|
||||
@@ -77,4 +78,10 @@
|
||||
+ public static boolean isSpiderCollidingWithWorldBorder(final Spider spider) {
|
||||
+ return true; // ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.isCollidingWithBorder(spider.level().getWorldBorder(), spider.getBoundingBox().inflate(ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_EPSILON))
|
||||
+ }
|
||||
+
|
||||
+ public static void dumpTickingInfo() {
|
||||
+ }
|
||||
+
|
||||
+ private static void dumpEntity(final Entity entity) {
|
||||
+ }
|
||||
+}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
@Nullable
|
||||
private KeyPair keyPair;
|
||||
@Nullable
|
||||
@@ -271,10 +_,33 @@
|
||||
@@ -271,10 +_,35 @@
|
||||
private final SuppressedExceptionCollector suppressedExceptions = new SuppressedExceptionCollector();
|
||||
private final DiscontinuousFrame tickFrame;
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
+ public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
|
||||
+ public int autosavePeriod;
|
||||
+ // Paper - don't store the vanilla dispatcher
|
||||
+ private boolean forceTicks;
|
||||
+ public boolean forceTicks;
|
||||
+ // CraftBukkit end
|
||||
+ // Spigot start
|
||||
+ public static final int TPS = 20;
|
||||
@@ -63,6 +63,8 @@
|
||||
+ @Deprecated(forRemoval = true) // Paper
|
||||
+ public final double[] recentTps = new double[ 3 ];
|
||||
+ // Spigot end
|
||||
+ public volatile boolean hasFullyShutdown; // Paper - Improved watchdog support
|
||||
+ public volatile boolean abnormalExit; // Paper - Improved watchdog support
|
||||
+ public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files
|
||||
+ public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
|
||||
+ private final Set<String> pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping
|
||||
|
||||
@@ -301,7 +301,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -271,12 +_,14 @@
|
||||
@@ -271,12 +_,15 @@
|
||||
}
|
||||
|
||||
if (this.rconThread != null) {
|
||||
@@ -314,6 +314,7 @@
|
||||
+ // this.remoteStatusListener.stop(); // Paper - don't wait for remote connections
|
||||
}
|
||||
+
|
||||
+ this.hasFullyShutdown = true; // Paper - Improved watchdog support
|
||||
+ System.exit(0); // CraftBukkit
|
||||
}
|
||||
|
||||
|
||||
@@ -12,11 +12,27 @@ public class ServerShutdownThread extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// Paper start - try to shutdown on main
|
||||
server.safeShutdown(false, false);
|
||||
for (int i = 1000; i > 0 && !server.hasStopped(); i -= 100) {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
if (server.hasStopped()) {
|
||||
while (!server.hasFullyShutdown) Thread.sleep(1000);
|
||||
return;
|
||||
}
|
||||
// Looks stalled, close async
|
||||
org.spigotmc.AsyncCatcher.enabled = false; // Spigot
|
||||
server.forceTicks = true;
|
||||
this.server.close();
|
||||
while (!server.hasFullyShutdown) Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
// Paper end
|
||||
} finally {
|
||||
org.apache.logging.log4j.LogManager.shutdown(); // Paper
|
||||
try {
|
||||
net.minecrell.terminalconsole.TerminalConsoleAppender.close(); // Paper - Use TerminalConsoleAppender
|
||||
//net.minecrell.terminalconsole.TerminalConsoleAppender.close(); // Paper - Move into stop
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class RestartCommand extends Command {
|
||||
// Paper end
|
||||
|
||||
// Paper start - copied from above and modified to return if the hook registered
|
||||
private static boolean addShutdownHook(String restartScript) {
|
||||
public static boolean addShutdownHook(String restartScript) {
|
||||
String[] split = restartScript.split(" ");
|
||||
if (split.length > 0 && new File(split[0]).isFile()) {
|
||||
Thread shutdownHook = new Thread(() -> {
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package org.spigotmc;
|
||||
|
||||
import io.papermc.paper.FeatureHooks;
|
||||
import io.papermc.paper.configuration.GlobalConfiguration;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MonitorInfo;
|
||||
import java.lang.management.ThreadInfo;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import io.papermc.paper.configuration.GlobalConfiguration;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
public class WatchdogThread extends Thread {
|
||||
|
||||
public static final boolean DISABLE_WATCHDOG = Boolean.getBoolean("disable.watchdog"); // Paper - Improved watchdog support
|
||||
private static WatchdogThread instance;
|
||||
private long timeoutTime;
|
||||
private boolean restart;
|
||||
@@ -36,6 +38,7 @@ public class WatchdogThread extends Thread {
|
||||
|
||||
public static void doStart(int timeoutTime, boolean restart) {
|
||||
if (WatchdogThread.instance == null) {
|
||||
if (timeoutTime <= 0) timeoutTime = 300; // Paper
|
||||
WatchdogThread.instance = new WatchdogThread(timeoutTime * 1000L, restart);
|
||||
WatchdogThread.instance.start();
|
||||
} else {
|
||||
@@ -60,14 +63,15 @@ public class WatchdogThread extends Thread {
|
||||
// Paper start
|
||||
Logger logger = Bukkit.getServer().getLogger();
|
||||
long currentTime = WatchdogThread.monotonicMillis();
|
||||
if (this.lastTick != 0 && this.timeoutTime > 0 && currentTime > this.lastTick + this.earlyWarningEvery && !Boolean.getBoolean("disable.watchdog")) { // Paper - Add property to disable
|
||||
boolean isLongTimeout = currentTime > this.lastTick + this.timeoutTime;
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
if (this.lastTick != 0 && this.timeoutTime > 0 && WatchdogThread.hasStarted && (!server.isRunning() || (currentTime > this.lastTick + this.earlyWarningEvery && !DISABLE_WATCHDOG))) { // Paper - add property to disable
|
||||
boolean isLongTimeout = currentTime > this.lastTick + this.timeoutTime || (!server.isRunning() && !server.hasStopped() && currentTime > this.lastTick + 1000);
|
||||
// Don't spam early warning dumps
|
||||
if (!isLongTimeout && (this.earlyWarningEvery <= 0 ||
|
||||
!hasStarted || currentTime < this.lastEarlyWarning + this.earlyWarningEvery ||
|
||||
currentTime < this.lastTick + this.earlyWarningDelay))
|
||||
continue;
|
||||
if (!isLongTimeout && MinecraftServer.getServer().hasStopped())
|
||||
if (!isLongTimeout && server.hasStopped())
|
||||
continue; // Don't spam early watchdog warnings during shutdown, we'll come back to this...
|
||||
this.lastEarlyWarning = currentTime;
|
||||
if (isLongTimeout) {
|
||||
@@ -106,6 +110,7 @@ public class WatchdogThread extends Thread {
|
||||
// Paper end - Different message for short timeout
|
||||
logger.log(Level.SEVERE, "------------------------------");
|
||||
logger.log(Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):"); // Paper
|
||||
FeatureHooks.dumpTickingInfo(); // Paper - log detailed tick information
|
||||
WatchdogThread.dumpThread(ManagementFactory.getThreadMXBean().getThreadInfo(MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE), logger);
|
||||
logger.log(Level.SEVERE, "------------------------------");
|
||||
|
||||
@@ -123,8 +128,23 @@ public class WatchdogThread extends Thread {
|
||||
logger.log(Level.SEVERE, "------------------------------");
|
||||
|
||||
if (isLongTimeout) {
|
||||
if (this.restart && !MinecraftServer.getServer().hasStopped()) {
|
||||
RestartCommand.restart();
|
||||
if (!server.hasStopped()) {
|
||||
AsyncCatcher.enabled = false; // Disable async catcher incase it interferes with us
|
||||
server.forceTicks = true;
|
||||
if (this.restart) {
|
||||
RestartCommand.addShutdownHook(SpigotConfig.restartScript);
|
||||
}
|
||||
// try one last chance to safe shutdown on main incase it 'comes back'
|
||||
server.abnormalExit = true;
|
||||
server.safeShutdown(false, this.restart);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!server.hasStopped()) {
|
||||
server.close();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Configuration status="WARN" shutdownHook="disable">
|
||||
<Appenders>
|
||||
<Queue name="ServerGuiConsole">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg{nolookups}%n" />
|
||||
|
||||
Reference in New Issue
Block a user