From 62e49b07a6198f230f931016de063a21cbca6e88 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Tue, 04 Dec 2007 11:11:59 +0000
Subject: [PATCH] Fix for 2615  : deadlock in changelog trimming

---
 opends/src/server/org/opends/server/replication/server/DbHandler.java |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/DbHandler.java b/opends/src/server/org/opends/server/replication/server/DbHandler.java
index fa86cbe..a373b24 100644
--- a/opends/src/server/org/opends/server/replication/server/DbHandler.java
+++ b/opends/src/server/org/opends/server/replication/server/DbHandler.java
@@ -89,7 +89,7 @@
   private boolean done = false;
   private DirectoryThread thread = null;
   private Object flushLock = new Object();
-  private ReplicationDbEnv dbenv;
+  private ReplicationServer replicationServer;
 
 
   // The High and low water mark for the max size of the msgQueue.
@@ -122,7 +122,6 @@
       ReplicationDbEnv dbenv, long generationId)
          throws DatabaseException
   {
-    this.dbenv = dbenv;
     this.serverId = id;
     this.baseDn = baseDn;
     this.trimage = replicationServer.getTrimage();
@@ -314,6 +313,11 @@
    */
   public void shutdown()
   {
+    if (shutdown == true)
+    {
+      return;
+    }
+
     shutdown  = true;
     synchronized (this)
     {
@@ -365,6 +369,7 @@
         mb.append(ERR_EXCEPTION_CHANGELOG_TRIM_FLUSH.get());
         mb.append(stackTraceToSingleLineString(end));
         logError(mb.toMessage());
+        replicationServer.shutdown();
         break;
       }
     }
@@ -424,6 +429,9 @@
       cursor.close();
     } catch (DatabaseException e)
     {
+      // mark shutdown for this db so that we don't try again to
+      // stop it from cursor.close() or methods called by cursor.close()
+      shutdown = true;
       cursor.close();
       throw (e);
     }

--
Gitblit v1.10.0