From a6be5db964ffa77a68b91966d99f6fa0b36b532e Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Tue, 29 May 2007 09:27:46 +0000
Subject: [PATCH] Fix for 1561 : ReplicationDomain.disable() should wait for all threads to die be fore returning

---
 opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java b/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
index 985d2f0..e601e1f 100644
--- a/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
+++ b/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
@@ -126,6 +126,12 @@
    */
   private static final DebugTracer TRACER = getTracer();
 
+  /**
+   * on shutdown, the server will wait for existing threads to stop
+   * during this timeout (in ms).
+   */
+  private static final int SHUTDOWN_JOIN_TIMEOUT = 30000;
+
   private ReplicationMonitor monitor;
 
   private ReplicationBroker broker;
@@ -1047,6 +1053,12 @@
 
     // stop the ReplicationBroker
     broker.stop();
+
+    //  wait for the listener thread to stop
+    for (ListenerThread thread : synchroThreads)
+    {
+      thread.shutdown();
+    }
   }
 
   /**
@@ -1745,6 +1757,17 @@
       thread.shutdown();
     }
     broker.stop(); // this will cut the session and wake-up the listeners
+
+    for (ListenerThread thread : synchroThreads)
+    {
+      try
+      {
+        thread.join(SHUTDOWN_JOIN_TIMEOUT);
+      } catch (InterruptedException e)
+      {
+        // ignore
+      }
+    }
   }
 
   /**

--
Gitblit v1.10.0