From c02dd7f87e9ba574f06e5cc1eb36ebeb76b9f446 Mon Sep 17 00:00:00 2001
From: mrossign <mrossign@localhost>
Date: Thu, 08 Oct 2009 16:02:17 +0000
Subject: [PATCH] - Addition of ReplServerStartDSMsg now sent to a DS connecting to a RS  in handshake phase instead of a ReplServerStartMsg. ReplServerStartDSMsg  contains same thing as ReplServerStartMsg but also contains

---
 opendj-sdk/opends/src/server/org/opends/server/replication/protocol/HeartbeatMonitor.java |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/HeartbeatMonitor.java b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/HeartbeatMonitor.java
index a60b658..518435b 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/HeartbeatMonitor.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/HeartbeatMonitor.java
@@ -69,6 +69,11 @@
    */
   private boolean shutdown = false;
 
+  /**
+   * Send StopMsg before session closure or not.
+   */
+  private boolean sendStopBeforeClose = false;
+
 
   /**
    * Create a heartbeat monitor thread.
@@ -76,13 +81,16 @@
    * @param session The session on which heartbeats are to be monitored.
    * @param heartbeatInterval The expected interval between heartbeats received
    * (in milliseconds).
+   * @param sendStopBeforeClose Should we send a StopMsg before closing the
+   *        session ?
    */
   public HeartbeatMonitor(String threadName, ProtocolSession session,
-                          long heartbeatInterval)
+                          long heartbeatInterval, boolean sendStopBeforeClose)
   {
     super(threadName);
     this.session = session;
     this.heartbeatInterval = heartbeatInterval;
+    this.sendStopBeforeClose = sendStopBeforeClose;
   }
 
   /**
@@ -117,6 +125,17 @@
           {
             // Heartbeat is well overdue so the server is assumed to be dead.
             logError(NOTE_HEARTBEAT_FAILURE.get(currentThread().getName()));
+            if (sendStopBeforeClose)
+            {
+              // V4 protocol introduces a StopMsg to properly end communications
+              try
+              {
+                session.publish(new StopMsg());
+              } catch(IOException ioe)
+              {
+                // Anyway, going to close session, so nothing to do
+              }
+            }
             session.close();
             break;
           }

--
Gitblit v1.10.0