manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1560527 - in /manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager: LockGate.java LockObject.java
Date Wed, 22 Jan 2014 21:49:35 GMT
Author: kwright
Date: Wed Jan 22 21:49:35 2014
New Revision: 1560527

URL: http://svn.apache.org/r1560527
Log:
Fix the way we handle retirement of records from pool.

Modified:
    manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockGate.java
    manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockObject.java

Modified: manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockGate.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockGate.java?rev=1560527&r1=1560526&r2=1560527&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockGate.java
(original)
+++ manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockGate.java
Wed Jan 22 21:49:35 2014
@@ -104,10 +104,13 @@ public class LockGate
     this.lockPool = lockPool;
   }
   
-  public synchronized void makeInvalid()
+  public void makeInvalid()
   {
-    this.lockPool = null;
-    lockObject.makeInvalid();
+    synchronized (lockObject)
+    {
+      this.lockPool = null;
+      lockObject.makeInvalid();
+    }
   }
 
   protected void waitForPermission(Long threadID)
@@ -196,13 +199,14 @@ public class LockGate
   public void leaveWriteLock()
     throws ManifoldCFException, InterruptedException, ExpiredObjectException
   {
-    // Leave, and if we succeed, flush from pool.
-    lockObject.leaveWriteLock();
-    synchronized (this)
+    synchronized (lockObject)
     {
-      if (lockPool == null)
-        throw new ExpiredObjectException("Invalid");
-      lockPool.releaseObject(lockKey, this);
+      // Leave, and if we succeed, flush from pool.
+      if (lockObject.leaveWriteLock())
+      {
+        if (lockPool != null)
+          lockPool.releaseObject(lockKey, this);
+      }
     }
   }
   
@@ -237,13 +241,14 @@ public class LockGate
   public void leaveNonExWriteLock()
     throws ManifoldCFException, InterruptedException, ExpiredObjectException
   {
-    // Leave, and if we succeed, flush from pool.
-    lockObject.leaveNonExWriteLock();
-    synchronized (this)
+    synchronized (lockObject)
     {
-      if (lockPool == null)
-        throw new ExpiredObjectException("Invalid");
-      lockPool.releaseObject(lockKey, this);
+      // Leave, and if we succeed, flush from pool.
+      if (lockObject.leaveNonExWriteLock())
+      {
+        if (lockPool != null)
+          lockPool.releaseObject(lockKey, this);
+      }
     }
   }
 
@@ -279,12 +284,13 @@ public class LockGate
     throws ManifoldCFException, InterruptedException, ExpiredObjectException
   {
     // Leave, and if we succeed, flush from pool.
-    lockObject.leaveReadLock();
-    synchronized (this)
+    synchronized (lockObject)
     {
-      if (lockPool == null)
-        throw new ExpiredObjectException("Invalid");
-      lockPool.releaseObject(lockKey, this);
+      if (lockObject.leaveReadLock())
+      {
+        if (lockPool != null)
+          lockPool.releaseObject(lockKey, this);
+      }
     }
   }
 

Modified: manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockObject.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockObject.java?rev=1560527&r1=1560526&r2=1560527&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockObject.java
(original)
+++ manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockObject.java
Wed Jan 22 21:49:35 2014
@@ -129,7 +129,7 @@ public class LockObject
     }
   }
 
-  public synchronized void leaveWriteLock()
+  public synchronized boolean leaveWriteLock()
     throws ManifoldCFException, InterruptedException, ExpiredObjectException
   {
     if (lockPool == null)
@@ -142,6 +142,7 @@ public class LockObject
 
     obtainedWrite = false;
     notifyAll();
+    return true;
   }
 
   protected void clearGlobalWriteLockNoWait()
@@ -246,7 +247,7 @@ public class LockObject
     }
   }
 
-  public synchronized void leaveNonExWriteLock()
+  public synchronized boolean leaveNonExWriteLock()
     throws ManifoldCFException, InterruptedException, ExpiredObjectException
   {
     if (lockPool == null)
@@ -257,13 +258,14 @@ public class LockObject
     if (obtainedNonExWrite > 1)
     {
       obtainedNonExWrite--;
-      return;
+      return false;
     }
 
     clearGlobalNonExWriteLock();
 
     obtainedNonExWrite--;
     notifyAll();
+    return true;
   }
 
   protected void clearGlobalNonExWriteLockNoWait()
@@ -357,7 +359,7 @@ public class LockObject
     }
   }
   
-  public synchronized void leaveReadLock()
+  public synchronized boolean leaveReadLock()
     throws ManifoldCFException, InterruptedException, ExpiredObjectException
   {
     if (lockPool == null)
@@ -368,13 +370,14 @@ public class LockObject
     if (obtainedRead > 1)
     {
       obtainedRead--;
-      return;
+      return false;
     }
     
     clearGlobalReadLock();
 
     obtainedRead--;
     notifyAll();
+    return true;
   }
 
   protected void clearGlobalReadLockNoWait()



Mime
View raw message