ozeigermann 2004/12/20 07:23:56
Modified: transaction/src/java/org/apache/commons/transaction/locking
GenericLockManager.java
Log:
Some fixes around global timeouts
Revision Changes Path
1.9 +22 -10
jakarta-commons/transaction/src/java/org/apache/commons/transaction/locking/GenericLockManager.java
Index: GenericLockManager.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/transaction/src/java/org/apache/commons/transaction/locking/GenericLockManager.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- GenericLockManager.java 19 Dec 2004 10:54:52 -0000 1.8
+++ GenericLockManager.java 20 Dec 2004 15:23:56 -0000 1.9
@@ -269,11 +269,9 @@
* @see LockManager#releaseAll(Object)
*/
public void releaseAll(Object ownerId) {
- // reset time out status for this owner
- if (timedOutOwners.remove(ownerId)) {
- // short cut if we were timed out there are no more locks
- return;
- }
+ // XXX even if we are timed out we can still have
+ // locks acquired because we might have been waiting for one
+ // while we were set to timed out
Set locks = (Set) globalOwners.get(ownerId);
if (locks != null) {
synchronized (locks) {
@@ -284,6 +282,8 @@
}
}
}
+ // reset time out status for this owner
+ timedOutOwners.remove(ownerId);
}
/**
@@ -373,7 +373,6 @@
if (timeout < now) {
releaseAll(ownerId);
timedOutOwners.add(ownerId);
- it.remove();
released = true;
}
}
@@ -381,6 +380,18 @@
return released;
}
+ protected boolean timeOut(Object ownerId) {
+ Long timeout = (Long)globalTimeouts.get(ownerId);
+ long now = System.currentTimeMillis();
+ if (timeout != null && timeout.longValue() < now) {
+ releaseAll(ownerId);
+ timedOutOwners.add(ownerId);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
protected long getNextGlobalConflictTimeout(Set conflicts) {
long minTimeout = -1;
long now = System.currentTimeMillis();
@@ -443,6 +454,7 @@
}
protected void timeoutCheck(Object ownerId) throws LockException {
+ timeOut(ownerId);
if (timedOutOwners.contains(ownerId)) {
throw new LockException(
"All locks of owner "
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]