mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

boli
24.06.2007 33bcc689c6711ea6ab6bb6ee709e8ac4cbb2ae65
Fix a issue where adding entries below a parent entry and modifying the parent entry causes lock expirations. All writer threads for the modify 
operations were being starved by the reader threads for the add operations. Changed the LockManager to observe fairness rules when granting
locks so waiting write locks are granted before read locks.

Fix for issue 1896
1 files modified
21 ■■■■■ changed files
opends/src/server/org/opends/server/types/LockManager.java 21 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/types/LockManager.java
@@ -217,7 +217,10 @@
          // and either return it or return null.
          readLock.unlock();
          readLock = existingLock.readLock();
          if (readLock.tryLock())
          try
          {
            if (readLock.tryLock(0, TimeUnit.SECONDS))
          {
            return readLock;
          }
@@ -226,6 +229,12 @@
            return null;
          }
        }
          catch(InterruptedException ie)
          {
            // This should never happen. Just return null
            return null;
          }
        }
        else
        {
          // If this happens, then it means that while we were waiting
@@ -421,7 +430,9 @@
          // and either return it or return null.
          writeLock.unlock();
          writeLock = existingLock.writeLock();
          if (writeLock.tryLock())
          try
          {
            if (writeLock.tryLock(0, TimeUnit.SECONDS))
          {
            return writeLock;
          }
@@ -430,6 +441,12 @@
            return null;
          }
        }
          catch(InterruptedException ie)
          {
            // This should never happen. Just return null
            return null;
          }
        }
        else
        {
          // If this happens, then it means that while we were waiting