Restructure try/finally blocks to ensure that we don't attempt to release

a transaction we were never able to start.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1771 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-10-04 01:31:43 +00:00
parent e26fd18b38
commit 0309b23a69
@@ -1,5 +1,5 @@
// //
// $Id: LocationProvider.java,v 1.17 2002/09/13 00:20:43 mdb Exp $ // $Id: LocationProvider.java,v 1.18 2002/10/04 01:31:43 mdb Exp $
package com.threerings.crowd.server; package com.threerings.crowd.server;
@@ -90,7 +90,6 @@ public class LocationProvider
return pmgr.getConfig(); return pmgr.getConfig();
} }
try {
// acquire a lock on the body object to ensure that rapid fire // acquire a lock on the body object to ensure that rapid fire
// moveTo requests don't break things // moveTo requests don't break things
if (!source.acquireLock("moveToLock")) { if (!source.acquireLock("moveToLock")) {
@@ -99,16 +98,20 @@ public class LocationProvider
throw new InvocationException(MOVE_IN_PROGRESS); throw new InvocationException(MOVE_IN_PROGRESS);
} }
PlaceObject place = pmgr.getPlaceObject();
try { try {
place.startTransaction(); PlaceObject place = pmgr.getPlaceObject();
source.startTransaction();
// the doubly nested try catch is to prevent failure if one or
// the other of the transactions fails to start
place.startTransaction();
try {
source.startTransaction();
try {
// remove them from any previous location // remove them from any previous location
leaveOccupiedPlace(source); leaveOccupiedPlace(source);
// generate a new occupant info record (which will add it // generate a new occupant info record (which will add
// to the target location) // it to the target location)
pmgr.buildOccupantInfo(source); pmgr.buildOccupantInfo(source);
// set the body's new location // set the body's new location
@@ -118,9 +121,11 @@ public class LocationProvider
place.addToOccupants(bodoid); place.addToOccupants(bodoid);
} finally { } finally {
place.commitTransaction();
source.commitTransaction(); source.commitTransaction();
} }
} finally {
place.commitTransaction();
}
} finally { } finally {
// and finally queue up a lock release event to release the // and finally queue up a lock release event to release the