From da01fbb447f17117ac3782e76ca783190230757f Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 24 Jan 2024 11:29:44 +0100 Subject: [PATCH] Reduce checkpoint exceptions by TCP retry and silent jar updates --- .../src/de/steamwar/core/CheckpointUtils.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/core/CheckpointUtils.java b/SpigotCore_Main/src/de/steamwar/core/CheckpointUtils.java index 15d063a..6f0af7f 100644 --- a/SpigotCore_Main/src/de/steamwar/core/CheckpointUtils.java +++ b/SpigotCore_Main/src/de/steamwar/core/CheckpointUtils.java @@ -69,8 +69,17 @@ public class CheckpointUtils { try { freezeInternal(path); } catch (Exception e) { + String message = e.getMessage() != null ? e.getMessage() : ""; + if(message.contains("Connected TCP socket")) { + Core.getInstance().getLogger().log(Level.INFO, "Connected TCP socket, waiting for checkpointing"); + Bukkit.getScheduler().runTaskLater(Core.getInstance(), CheckpointUtils::freeze, 1); + return; + } + Bukkit.shutdown(); - throw new SecurityException(e); + + if(message.contains("Can't dump ghost file")) // File/Jar has been updated + throw new SecurityException(e); } finally { // Delete checkpoint try (Stream stream = Files.walk(path)) { @@ -109,8 +118,6 @@ public class CheckpointUtils { try { criu.checkpointJVM(); } catch (JVMCRIUException e) { - Bukkit.shutdown(); - Path logfile = path.resolve("criu.log"); if(logfile.toFile().exists()) throw new IllegalStateException("Could not create checkpoint, criu log:\n" + new String(Files.readAllBytes(logfile)), e);