summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2009-12-20 02:54:41 +0000
committerBrian S. O'Neill <bronee@gmail.com>2009-12-20 02:54:41 +0000
commitca6d4484142d8144f7567a37ed448babe294fda8 (patch)
tree77be2d6d0e15bf0e91ae72982a815d0921eb067b /src/main/java
parenta4f685b99989203068d6c5f81bc49cee5a4c41cc (diff)
Allow transaction to attach if existing scope is inactive.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/amazon/carbonado/txn/TransactionManager.java2
-rw-r--r--src/main/java/com/amazon/carbonado/txn/TransactionScope.java10
2 files changed, 11 insertions, 1 deletions
diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionManager.java b/src/main/java/com/amazon/carbonado/txn/TransactionManager.java
index 528ade5..36d2e22 100644
--- a/src/main/java/com/amazon/carbonado/txn/TransactionManager.java
+++ b/src/main/java/com/amazon/carbonado/txn/TransactionManager.java
@@ -98,7 +98,7 @@ public abstract class TransactionManager<Txn> {
// Called by TransactionScope.
boolean setLocalScope(TransactionScope<Txn> scope, boolean detached) {
TransactionScope<Txn> existing = mLocalScope.get();
- if ((existing == null && detached) || existing == scope) {
+ if (((existing == null || existing.isInactive()) && detached) || existing == scope) {
mLocalScope.set(scope);
return true;
}
diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java
index 29c173c..bce8ca6 100644
--- a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java
+++ b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java
@@ -258,6 +258,16 @@ public class TransactionScope<Txn> {
}
}
+ // Called by TransactionManager.
+ boolean isInactive() {
+ mLock.lock();
+ try {
+ return mActive == null;
+ } finally {
+ mLock.unlock();
+ }
+ }
+
/**
* Exits all transactions and closes all cursors. Should be called only
* when repository is closed.