[jbosscache-commits] JBoss Cache SVN: r5459 - core/branches/1.4.X/src/org/jboss/cache/interceptors.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Tue Mar 25 13:52:13 EDT 2008
Author: mircea.markus
Date: 2008-03-25 13:52:13 -0400 (Tue, 25 Mar 2008)
New Revision: 5459
Modified:
core/branches/1.4.X/src/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
Log:
JBCACHE-1292
Modified: core/branches/1.4.X/src/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/branches/1.4.X/src/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-03-24 23:02:14 UTC (rev 5458)
+++ core/branches/1.4.X/src/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-03-25 17:52:13 UTC (rev 5459)
@@ -174,11 +174,20 @@
// release the locks for the given TX
if (fqn != null)
{
+ long timeout = zeroLockTimeout ? 0 : lock_acquisition_timeout;
+ // make sure we can bail out of this loop
+ long cutoffTime = System.currentTimeMillis() + timeout;
+ boolean firstTry = true;
if (createIfNotExists)
{
do
{
+ if (!firstTry && System.currentTimeMillis() > cutoffTime)
+ {
+ throw new TimeoutException("Unable to acquire lock on Fqn " + fqn + " after " + timeout + " millis");
+ }
lock(fqn, ctx.getGlobalTransaction(), lock_type, recursive, zeroLockTimeout ? 0 : lock_timeout, createIfNotExists, storeLockedNode, isRemoveData);
+ firstTry = false;
}
while(!cache.exists(fqn)); // keep trying until we have the lock (fixes concurrent remove())
// terminates successfully, or with (Timeout)Exception
More information about the jbosscache-commits
mailing list