Fixes for shutdown sequence, including prevention of a race condition
* Throw an exception if any events, runnables or messages are posted after shutdown. These were previosuly being silently ignored. We really should know about them. * Don't exit the connection manager thread until the object manager thread exits. This fixes a race condition where the wakeup time of the conmgr thread would determine if it shutdown before or after the object manager, meaning it would sometimes ignore messages around shutdown time. * Add a shutdown constraint to make the client manager shutdown before the invoker/event/conmgr threads. This gives a single point in the shutdown sequence that applications can use as a constraint (TODO: shutdown groups?) * Emit a log message for each shutdown method call. This could be very useful in production. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5491 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -158,6 +158,17 @@ public class PresentsServer
|
||||
|
||||
// initialize the time base services
|
||||
TimeBaseProvider.init(_invmgr, _omgr);
|
||||
|
||||
// Make the client manager shut down before the invoker and dobj threads. This will help
|
||||
// application code to avoid long chains of shutdown constraints (e.g. msoy bureau manager).
|
||||
// TODO: is this check needed?
|
||||
if (_invoker instanceof PresentsInvoker) {
|
||||
_shutmgr.addConstraint(
|
||||
_clmgr, ShutdownManager.Constraint.RUNS_BEFORE, (PresentsInvoker)_invoker);
|
||||
|
||||
} else {
|
||||
log.warning("Invoker is not a PresentsInvoker", "invoker", _invoker);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user