Start transactions outside of the try-finally clause so that if there

is a problem with starting a transaction, we don't get an exception
for failing to commit the transaction.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2712 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2003-07-16 18:03:30 +00:00
parent 2726f6a29d
commit 829f3ad0eb
4 changed files with 30 additions and 24 deletions
@@ -1,5 +1,5 @@
// //
// $Id: LocationProvider.java,v 1.19 2003/02/26 17:54:56 mdb Exp $ // $Id: LocationProvider.java,v 1.20 2003/07/16 18:03:30 ray Exp $
package com.threerings.crowd.server; package com.threerings.crowd.server;
@@ -155,8 +155,8 @@ public class LocationProvider
PlaceObject pold = (PlaceObject)_omgr.getObject(oldloc); PlaceObject pold = (PlaceObject)_omgr.getObject(oldloc);
if (pold != null) { if (pold != null) {
Integer key = new Integer(bodoid); Integer key = new Integer(bodoid);
pold.startTransaction();
try { try {
pold.startTransaction();
// remove their occupant info (which is keyed on oid) // remove their occupant info (which is keyed on oid)
pold.removeFromOccupantInfo(key); pold.removeFromOccupantInfo(key);
// and remove them from the occupant list // and remove them from the occupant list
@@ -1,5 +1,5 @@
// //
// $Id: GameManager.java,v 1.66 2003/06/29 23:11:23 mdb Exp $ // $Id: GameManager.java,v 1.67 2003/07/16 18:03:30 ray Exp $
package com.threerings.parlor.game; package com.threerings.parlor.game;
@@ -659,8 +659,8 @@ public class GameManager extends PlaceManager
return; return;
} }
_gameobj.startTransaction();
try { try {
_gameobj.startTransaction();
// let the derived class do its pre-end stuff // let the derived class do its pre-end stuff
gameWillEnd(); gameWillEnd();
@@ -1,5 +1,5 @@
// //
// $Id: InvocationDirector.java,v 1.28 2003/07/12 22:34:03 mdb Exp $ // $Id: InvocationDirector.java,v 1.29 2003/07/16 18:03:30 ray Exp $
package com.threerings.presents.client; package com.threerings.presents.client;
@@ -335,8 +335,8 @@ public class InvocationDirector
_clobj.addListener(InvocationDirector.this); _clobj.addListener(InvocationDirector.this);
// reregister our receivers // reregister our receivers
_clobj.startTransaction();
try { try {
_clobj.startTransaction();
Iterator iter = receivers.entries(); Iterator iter = receivers.entries();
while (iter.hasNext()) { while (iter.hasNext()) {
_clobj.addToReceivers((Registration)iter.next()); _clobj.addToReceivers((Registration)iter.next());
@@ -1,5 +1,5 @@
// //
// $Id: SpotSceneManager.java,v 1.41 2003/06/03 21:41:33 ray Exp $ // $Id: SpotSceneManager.java,v 1.42 2003/07/16 18:03:30 ray Exp $
package com.threerings.whirled.spot.server; package com.threerings.whirled.spot.server;
@@ -423,20 +423,23 @@ public class SpotSceneManager extends SceneManager
removeFromCluster(body.getOid()); removeFromCluster(body.getOid());
put(body.getOid(), body); put(body.getOid(), body);
_ssobj.startTransaction();
try { try {
body.startTransaction(); body.startTransaction();
_ssobj.startTransaction(); try {
bodyAdded(this, body); // do the hokey pokey bodyAdded(this, body); // do the hokey pokey
if (_clobj != null) { if (_clobj != null) {
((ClusteredBodyObject)body).setClusterOid( ((ClusteredBodyObject)body).setClusterOid(
_clobj.getOid()); _clobj.getOid());
_clobj.addToOccupants(body.getOid()); _clobj.addToOccupants(body.getOid());
_ssobj.updateClusters(_cluster); _ssobj.updateClusters(_cluster);
}
} finally {
body.commitTransaction();
} }
} finally { } finally {
body.commitTransaction();
_ssobj.commitTransaction(); _ssobj.commitTransaction();
} }
@@ -454,19 +457,22 @@ public class SpotSceneManager extends SceneManager
return; return;
} }
body.startTransaction();
try { try {
body.startTransaction();
_ssobj.startTransaction(); _ssobj.startTransaction();
((ClusteredBodyObject)body).setClusterOid(-1); try {
bodyRemoved(this, body); // do the hokey pokey ((ClusteredBodyObject)body).setClusterOid(-1);
bodyRemoved(this, body); // do the hokey pokey
if (_clobj != null) { if (_clobj != null) {
_clobj.removeFromOccupants(bodyOid); _clobj.removeFromOccupants(bodyOid);
_ssobj.updateClusters(_cluster); _ssobj.updateClusters(_cluster);
}
} finally {
_ssobj.commitTransaction();
} }
} finally { } finally {
_ssobj.commitTransaction();
body.commitTransaction(); body.commitTransaction();
} }