jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1040090 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/FineGrainedISMLocking.java
Date Mon, 29 Nov 2010 12:45:14 GMT
Author: jukka
Date: Mon Nov 29 12:45:14 2010
New Revision: 1040090

URL: http://svn.apache.org/viewvc?rev=1040090&view=rev
Log:
JCR-2820: FineGrainedISMLocking problems

Use the transaction id to identify the current thread for locking purposes.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/FineGrainedISMLocking.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/FineGrainedISMLocking.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/FineGrainedISMLocking.java?rev=1040090&r1=1040089&r2=1040090&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/FineGrainedISMLocking.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/FineGrainedISMLocking.java
Mon Nov 29 12:45:14 2010
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.core.state;
 
+import static org.apache.jackrabbit.core.TransactionContext.getCurrentThreadId;
+import static org.apache.jackrabbit.core.TransactionContext.isSameThreadId;
+
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -52,7 +55,7 @@ public class FineGrainedISMLocking imple
      */
     private WriteLockImpl activeWriter;
 
-    private volatile Thread activeWriterThread;
+    private volatile Object activeWriterId;
 
     private ReadWriteLock writerStateRWLock = new WriterPreferenceReadWriteLock();
 
@@ -79,7 +82,7 @@ public class FineGrainedISMLocking imple
      */
     public ReadLock acquireReadLock(ItemId id)
             throws InterruptedException {
-        if (activeWriterThread == Thread.currentThread()) {
+        if (isSameThreadId(activeWriterId, getCurrentThreadId())) {
             // we hold the write lock
             readLockMap.addLock(id);
             return new ReadLockImpl(id);
@@ -126,7 +129,7 @@ public class FineGrainedISMLocking imple
                 if (activeWriter == null
                         && !readLockMap.hasDependency(changeLog)) {
                     activeWriter = new WriteLockImpl(changeLog);
-                    activeWriterThread = Thread.currentThread();
+                    activeWriterId = getCurrentThreadId();
                     return activeWriter;
                 } else {
                     signal = new Latch();
@@ -164,7 +167,7 @@ public class FineGrainedISMLocking imple
             }
             try {
                 activeWriter = null;
-                activeWriterThread = null;
+                activeWriterId = null;
                 notifyWaitingReaders();
                 notifyWaitingWriters();
             } finally {
@@ -186,7 +189,6 @@ public class FineGrainedISMLocking imple
             }
             try {
                 activeWriter = null;
-                activeWriterThread = null;
                 // only notify waiting readers since we still hold a down
                 // graded lock, which is kind of exclusiv with respect to
                 // other writers
@@ -224,7 +226,7 @@ public class FineGrainedISMLocking imple
             }
             try {
                 readLockMap.removeLock(id);
-                if (activeWriterThread != Thread.currentThread()) {
+                if (!isSameThreadId(activeWriterId, getCurrentThreadId())) {
                     // only notify waiting writers if we do *not* hold a write
                     // lock at the same time. that would be a waste of cpu time.
                     notifyWaitingWriters();



Mime
View raw message