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

Jean-Noel Rouvignac
22.00.2013 71bedb2ae75c5513f8798dafa3fc64d3efd691d5
Found and fixed a new deadlock with read vs. write locks.

ReplicationDB.java:
Always unlock the readLock when no cursor is held. Fix is similar to r9542 for DraftCNDB.DraftCNDBCursor .
1 files modified
18 ■■■■■ changed files
opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java 18 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java
@@ -576,6 +576,7 @@
      // unlock it when throwing an exception.
      dbCloseLock.readLock().lock();
      boolean cursorHeld = false;
      Cursor localCursor = null;
      try
      {
@@ -609,6 +610,7 @@
          }
        }
        cursor = localCursor;
        cursorHeld = cursor != null;
      }
      catch (ChangelogException e)
      {
@@ -622,6 +624,13 @@
        closeAndReleaseReadLock(localCursor);
        throw new ChangelogException(e);
      }
      finally
      {
        if (!cursorHeld)
        {
          dbCloseLock.readLock().unlock();
        }
      }
    }
    private ReplServerDBCursor() throws ChangelogException
@@ -632,6 +641,7 @@
      // We'll go on only if no close or no clear is running
      dbCloseLock.readLock().lock();
      boolean cursorHeld = false;
      Transaction localTxn = null;
      Cursor localCursor = null;
      try
@@ -652,6 +662,7 @@
        txn = localTxn;
        cursor = localCursor;
        cursorHeld = cursor != null;
      }
      catch (ChangelogException e)
      {
@@ -665,6 +676,13 @@
        abort(localTxn);
        throw new ChangelogException(e);
      }
      finally
      {
        if (!cursorHeld)
        {
          dbCloseLock.readLock().unlock();
        }
      }
    }
    private void abort(Transaction localTxn)