From 6ee1440f6f56ac066f97383315b2798287f0821a Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Wed, 23 Mar 2011 22:27:01 +0000
Subject: [PATCH] Fix issue OpenDJ-95: Socket leak and constant disconnect/reconnect when a directory server can no longer reach its connected replication server

---
 opends/src/server/org/opends/server/replication/protocol/HeartbeatMonitor.java |   29 +----------------------------
 1 files changed, 1 insertions(+), 28 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/protocol/HeartbeatMonitor.java b/opends/src/server/org/opends/server/replication/protocol/HeartbeatMonitor.java
index 5a0688b..854a7b2 100644
--- a/opends/src/server/org/opends/server/replication/protocol/HeartbeatMonitor.java
+++ b/opends/src/server/org/opends/server/replication/protocol/HeartbeatMonitor.java
@@ -35,8 +35,6 @@
 
 import org.opends.server.loggers.debug.DebugTracer;
 
-import java.io.IOException;
-
 import org.opends.server.api.DirectoryThread;
 
 /**
@@ -71,27 +69,18 @@
   private volatile boolean shutdown = false;
 
   /**
-   * Send StopMsg before session closure or not.
-   */
-  private final boolean sendStopBeforeClose;
-
-
-  /**
    * Create a heartbeat monitor thread.
    * @param threadName The name of the heartbeat thread.
    * @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, boolean sendStopBeforeClose)
+                          long heartbeatInterval)
   {
     super(threadName);
     this.session = session;
     this.heartbeatInterval = heartbeatInterval;
-    this.sendStopBeforeClose = sendStopBeforeClose;
   }
 
   /**
@@ -126,18 +115,6 @@
           {
             // 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;
           }
@@ -160,10 +137,6 @@
         }
       }
     }
-    catch (IOException e)
-    {
-      // Hope that's OK.
-    }
     finally
     {
       if (debugEnabled())

--
Gitblit v1.10.0