Don't allow the dummy DObject to be destroyed. That shouldn't happen in the normal course of
operations, but previously if someone called destroy on an uninitialized DObject or called PresentsDObjectManager.destroyObject with its oid, it'd be destroyed. Subscribing to objects depends on that object existing, so if it's destroyed, the server will continue to function normally except that subscription requests will be silently dropped. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5851 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -367,6 +367,10 @@ public class DObject
|
||||
*/
|
||||
public void destroy ()
|
||||
{
|
||||
if (_oid == 0) {
|
||||
log.warning("Denying request to destroy an uninitialized object!", new Exception());
|
||||
return;
|
||||
}
|
||||
postEvent(new ObjectDestroyedEvent(_oid));
|
||||
}
|
||||
|
||||
|
||||
@@ -96,9 +96,9 @@ public class PresentsDObjectMgr
|
||||
{
|
||||
// create a dummy object to live as oid zero and use that for some internal event trickery
|
||||
DObject dummy = new DObject();
|
||||
dummy.setOid(0);
|
||||
dummy.setOid(DUMMY_OID);
|
||||
dummy.setManager(this);
|
||||
_objects.put(0, new DObject());
|
||||
_objects.put(DUMMY_OID, new DObject());
|
||||
|
||||
// register a couple of reports with the report manager
|
||||
repmgr.registerReporter(ReportManager.DEFAULT_TYPE, new ReportManager.Reporter() {
|
||||
@@ -268,6 +268,10 @@ public class PresentsDObjectMgr
|
||||
// from interface RootDObjectManager
|
||||
public void destroyObject (int oid)
|
||||
{
|
||||
if (oid == DUMMY_OID) {
|
||||
log.warning("Denying request to destroy the dummy object!", new Exception());
|
||||
return;
|
||||
}
|
||||
// queue up an object destroyed event
|
||||
postEvent(new ObjectDestroyedEvent(oid));
|
||||
}
|
||||
@@ -412,6 +416,11 @@ public class PresentsDObjectMgr
|
||||
{
|
||||
int oid = target.getOid();
|
||||
|
||||
if (oid == DUMMY_OID) {
|
||||
log.warning("Denying attempt to destroy dummy object!", new Exception());
|
||||
return false;
|
||||
}
|
||||
|
||||
// log.info("Removing destroyed object from table", "oid", oid);
|
||||
|
||||
// remove the object from the table
|
||||
@@ -871,7 +880,7 @@ public class PresentsDObjectMgr
|
||||
|
||||
public AccessObjectEvent (int oid, Subscriber<T> target, int action)
|
||||
{
|
||||
super(0); // target the bogus object
|
||||
super(DUMMY_OID); // target the bogus object
|
||||
_oid = oid;
|
||||
_target = target;
|
||||
_action = action;
|
||||
@@ -1067,4 +1076,10 @@ public class PresentsDObjectMgr
|
||||
|
||||
/** The default size of an oid list refs vector. */
|
||||
protected static final int DEFREFVEC_SIZE = 4;
|
||||
|
||||
/**
|
||||
* The oid of the DOject created during object manager startup that isn't actually
|
||||
* distributed.
|
||||
*/
|
||||
protected static final int DUMMY_OID = 0;
|
||||
}
|
||||
|
||||
@@ -962,7 +962,7 @@ public class PresentsSession
|
||||
// from interface ProxySubscriber
|
||||
public void eventReceived (DEvent event)
|
||||
{
|
||||
if (event instanceof PresentsDObjectMgr.AccessObjectEvent) {
|
||||
if (event instanceof PresentsDObjectMgr.AccessObjectEvent<?>) {
|
||||
log.warning("Ignoring event that shouldn't be forwarded " + event + ".",
|
||||
new Exception());
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user