diff --git a/htroot/Steering.java b/htroot/Steering.java index 9a95f338f..3eff070bd 100644 --- a/htroot/Steering.java +++ b/htroot/Steering.java @@ -69,7 +69,7 @@ public class Steering { if (post.containsKey("shutdown")) { ss.setConfig("restart", "false"); - sb.terminate(); + sb.terminate(3000); prop.put("info", 3); return prop; } diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java index 52f29a31e..c6fbc7c9c 100644 --- a/source/de/anomic/plasma/plasmaSwitchboard.java +++ b/source/de/anomic/plasma/plasmaSwitchboard.java @@ -2219,6 +2219,11 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser } } + public void terminate(long delay) { + if (delay <= 0) throw new IllegalArgumentException("The shutdown delay must be greater than 0."); + (new delayedShutdown(this,delay)).start(); + } + public void terminate() { this.terminate = true; this.shutdownSync.V(); @@ -2233,3 +2238,21 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser return this.terminate; } } + +class delayedShutdown extends Thread { + private plasmaSwitchboard sb; + private long delay; + public delayedShutdown(plasmaSwitchboard sb, long delay) { + this.sb = sb; + this.delay = delay; + } + + public void run() { + try { + Thread.sleep(delay); + } catch (InterruptedException e) { + e.printStackTrace(); + } + this.sb.terminate(); + } +}