jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r349676 - /incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Date Tue, 29 Nov 2005 08:59:40 GMT
Author: mreutegg
Date: Tue Nov 29 00:59:33 2005
New Revision: 349676

URL: http://svn.apache.org/viewcvs?rev=349676&view=rev
Log:
Fix potential deadlock in SharedItemStateManager

Because of the writer preference it was possible that reading threads were blocked even though
a thread that finished storing changes through the PM already released the write lock.
Modified the lock to a reader preference read-write lock.

For a discussion see: http://thread.gmane.org/gmane.comp.apache.jackrabbit.devel/4507

Modified:
    incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java

Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=349676&r1=349675&r2=349676&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Tue Nov 29 00:59:33 2005
@@ -144,7 +144,16 @@
      * Read-/Write-Lock to synchronize access on this item state manager.
      */
     private final ReadWriteLock rwLock =
-            new ReentrantWriterPreferenceReadWriteLock();
+            new ReentrantWriterPreferenceReadWriteLock() {
+                /**
+                 * Allow reader when there is no active writer, or current
+                 * thread owns the write lock (reentrant).
+                 */
+                protected boolean allowReader() {
+                    return activeWriter_ == null ||
+                      activeWriter_ == Thread.currentThread();
+                }
+            };
 
     /**
      * Creates a new <code>SharedItemStateManager</code> instance.



Mime
View raw message