Attempt to catch and recover from fatal errors. If some rogue event

listener tries to 'new int[Integer.MAX_VALUE]' or infinitely loop, they
will get the smack down and we will go on about our business.

If things have actually gone pear shaped and we are failing on every
event, we'll hit the 30 fatal events in 60 seconds cap and stick a fork in
ourselves.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2957 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2004-02-21 00:04:40 +00:00
parent cd2d0ef47b
commit 813e7b0d47
@@ -1,5 +1,5 @@
//
// $Id: PresentsDObjectMgr.java,v 1.39 2004/02/09 02:13:35 mdb Exp $
// $Id: PresentsDObjectMgr.java,v 1.40 2004/02/21 00:04:40 mdb Exp $
package com.threerings.presents.server;
@@ -15,6 +15,7 @@ import com.samskivert.util.Histogram;
import com.samskivert.util.Queue;
import com.samskivert.util.SortableArrayList;
import com.samskivert.util.StringUtil;
import com.samskivert.util.Throttle;
import com.threerings.presents.Log;
import com.threerings.presents.dobj.*;
@@ -321,6 +322,18 @@ public class PresentsDObjectMgr
Log.warning("Failure processing event [event=" + event +
", target=" + target + "].");
Log.logStackTrace(e);
} catch (OutOfMemoryError oome) {
Log.logStackTrace(oome);
if (_fatalThrottle.throttleOp()) {
throw oome;
}
} catch (StackOverflowError soe) {
Log.logStackTrace(soe);
if (_fatalThrottle.throttleOp()) {
throw soe;
}
}
// track the number of events dispatched
@@ -903,6 +916,11 @@ public class PresentsDObjectMgr
/** The last time at which we generated a report. */
protected long _lastReportStamp;
/** Track fatal errors so that we can stick a fork in ourselves if
* things get too far out of hand. More than 30 fatal errors in the
* span of a minute and we throw in the towel. */
protected Throttle _fatalThrottle = new Throttle(30, 60*1000L);
/** Used to track oid list references of distributed objects. */
protected HashIntMap _refs = new HashIntMap();