diff --git a/src/java/com/threerings/presents/server/net/ConnectionManager.java b/src/java/com/threerings/presents/server/net/ConnectionManager.java index 553a7e2e2..7b32d9e49 100644 --- a/src/java/com/threerings/presents/server/net/ConnectionManager.java +++ b/src/java/com/threerings/presents/server/net/ConnectionManager.java @@ -112,6 +112,18 @@ public class ConnectionManager extends LoopingThread return _author; } + /** + * Instructs us to execute the specified runnable when the connection + * manager thread exits. Note: this will be executed on the + * connection manager thread, so don't do anything dangerous. Only one + * action may be specified and it may be cleared by calling this + * method with null. + */ + public synchronized void setShutdownAction (Runnable onExit) + { + _onExit = onExit; + } + /** * Returns our current runtime statistics. When the stats are fetched * the counters are rolled to the next bucket. 60 buckets are tracked. @@ -534,7 +546,16 @@ public class ConnectionManager extends LoopingThread // documentation inherited protected void didShutdown () { - Log.info("Connection Manager thread exited."); + Runnable onExit = null; + synchronized (this) { + onExit = _onExit; + } + if (onExit != null) { + Log.info("Connection Manager thread exited (running onExit)."); + onExit.run(); + } else { + Log.info("Connection Manager thread exited."); + } } /** @@ -754,6 +775,9 @@ public class ConnectionManager extends LoopingThread /** Our current runtime stats. */ protected ConMgrStats _stats; + /** A runnable to execute when the connection manager thread exits. */ + protected Runnable _onExit; + /** Used to create an overflow queue on the first partial write. */ protected PartialWriteHandler _oflowHandler = new PartialWriteHandler() { public void handlePartialWrite (Connection conn, ByteBuffer msgbuf) {