From 39d78ca1702b263b66948c483ade1a88620367a7 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Mon, 07 Sep 2009 15:01:28 +0000
Subject: [PATCH] Fix for 4171 : Replica initialization hangs if replication servers unreachable  

---
 opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java b/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
index 46ed7dd..ef5e145 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
@@ -65,7 +65,11 @@
 import org.opends.server.replication.protocol.AckMsg;
 import org.opends.server.replication.protocol.ChangeTimeHeartbeatMsg;
 import org.opends.server.replication.protocol.ChangeStatusMsg;
+import org.opends.server.replication.protocol.DoneMsg;
+import org.opends.server.replication.protocol.EntryMsg;
 import org.opends.server.replication.protocol.ErrorMsg;
+import org.opends.server.replication.protocol.InitializeRequestMsg;
+import org.opends.server.replication.protocol.InitializeTargetMsg;
 import org.opends.server.replication.protocol.MonitorMsg;
 import org.opends.server.replication.protocol.MonitorRequestMsg;
 import org.opends.server.replication.protocol.ProtocolVersion;
@@ -1529,7 +1533,11 @@
 
     // Test the message for which a ReplicationServer is expected
     // to be the destination
-    if (msg.getDestination() == this.replicationServer.getServerId())
+    if (!(msg instanceof InitializeRequestMsg) &&
+        !(msg instanceof InitializeTargetMsg) &&
+        !(msg instanceof EntryMsg) &&
+        !(msg instanceof DoneMsg) &&
+        (msg.getDestination() == this.replicationServer.getServerId()))
     {
       if (msg instanceof ErrorMsg)
       {
@@ -1665,6 +1673,22 @@
       {
         logError(NOTE_ERR_ROUTING_TO_SERVER.get(
           msg.getClass().getCanonicalName()));
+
+        MessageBuilder mb1 = new MessageBuilder();
+        mb1.append(
+            NOTE_ERR_ROUTING_TO_SERVER.get(msg.getClass().getCanonicalName()));
+        mb1.append("serverID:" + msg.getDestination());
+        ErrorMsg errMsg = new ErrorMsg(
+          msg.getsenderID(), mb1.toMessage());
+        try
+        {
+          senderHandler.send(errMsg);
+        } catch (IOException ioe1)
+        {
+          // an error happened on the sender session trying to recover
+          // from an error on the receiver session.
+          // Not much more we can do at this point.
+        }
       }
       return;
     }

--
Gitblit v1.10.0