From 502b281e12897b02a6ed1cc64fd4a9ca8e6a5c5f Mon Sep 17 00:00:00 2001 From: Tom Denham Date: Thu, 13 Dec 2012 16:03:30 +0000 Subject: [PATCH] Fix issues reported by Ingo on the dev mailing list where Jitsi fails to shutdown properly. The fix relies on just calling System.exit() when we choose to shut down and the felix shutdown hooks take care of stopping everything nicely. I've replaced the System.exit() call in the shutdown-timeout plugin with Runtime.getRuntime().halt() which doesn't run the shutdown hooks in felix so can't be blocked. We'll need to keep a close eye on this to ensure that we're not resorting to the halt() in the shutdown-plugin in the mainline case. In future I hope to add a thread dump to the log just before we call .halt() to help diagnose problems in this area. --- .../sip/communicator/impl/gui/UIServiceImpl.java | 13 +++---------- .../impl/shutdowntimeout/ShutdownTimeout.java | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java index 9f2c290e5..5f8442d0c 100644 --- a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java +++ b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java @@ -31,7 +31,6 @@ import net.java.sip.communicator.impl.gui.utils.Constants; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.service.gui.ContactList; import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; import net.java.sip.communicator.service.protocol.*; @@ -1201,15 +1200,9 @@ public void beginShutdown() } finally { - try - { - GuiActivator.bundleContext.getBundle(0).stop(); - } - catch (BundleException ex) - { - logger.error("Failed to being gentle shutdown of Felix.", ex); - System.exit(0); - } + // Just exit. The shutdown hook in felix ensures that we stop + // everything nicely. + System.exit(0); } } diff --git a/src/net/java/sip/communicator/impl/shutdowntimeout/ShutdownTimeout.java b/src/net/java/sip/communicator/impl/shutdowntimeout/ShutdownTimeout.java index e221c0fc1..22bc36106 100644 --- a/src/net/java/sip/communicator/impl/shutdowntimeout/ShutdownTimeout.java +++ b/src/net/java/sip/communicator/impl/shutdowntimeout/ShutdownTimeout.java @@ -109,7 +109,7 @@ public void run() + shutDownTimeout + "ms."); wait(shutDownTimeout); logger.error("Failed to gently shutdown. Forcing exit."); - System.exit(SYSTEM_EXIT_CODE); + Runtime.getRuntime().halt(SYSTEM_EXIT_CODE); }catch (InterruptedException ex){ if (logger.isDebugEnabled()) logger.debug("Interrupted shutdown timer.");