From 574b552348f1f8a8740594b35fda1297ad62bfbe Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Wed, 03 Jun 2009 15:12:16 +0000
Subject: [PATCH] fix for issue 4028 : error 53 returned to application during reconnection

---
 opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java |    5 +++--
 opends/src/server/org/opends/server/replication/service/ReplicationBroker.java    |   12 +++++++++++-
 opends/src/server/org/opends/server/replication/service/ReplicationDomain.java    |   15 +++++++++++++++
 3 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java b/opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
index 98eeb88..78bda99 100644
--- a/opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
+++ b/opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -642,8 +642,9 @@
     if (isolationpolicy.equals(IsolationPolicy.REJECT_ALL_UPDATES))
     {
       // this isolation policy specifies that the updates are denied
-      // when the broker is not connected.
-      return isConnected();
+      // when the broker had problems during the connection phase
+      // Updates are still accepted if the broker is currently connecting..
+      return !hasConnectionError();
     }
     // we should never get there as the only possible policies are
     // ACCEPT_ALL_UPDATES and REJECT_ALL_UPDATES
diff --git a/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java b/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
index c20eced..427fea2 100644
--- a/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
+++ b/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
@@ -369,7 +369,6 @@
 
       if (rsInfos.size() > 0)
       {
-
         // At least one server answered, find the best one.
         String bestServer = computeBestReplicationServer(state, rsInfos,
           serverId, baseDn, groupId);
@@ -1838,4 +1837,15 @@
       }
     }
   }
+
+  /**
+   * Check if the broker could not find any Replication Server and therefore
+   * connection attempt failed.
+   *
+   * @return true if the server could not connect to any Replication Server.
+   */
+  public boolean hasConnectionError()
+  {
+    return connectionError;
+  }
 }
diff --git a/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java b/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
index 2332610..c87076a 100644
--- a/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
+++ b/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
@@ -2005,6 +2005,21 @@
   }
 
   /**
+   * Check if the domain has a connection error.
+   * A Connection error happens when the broker could not be created
+   * or when the broker could not find any ReplicationServer to connect to.
+   *
+   * @return true if the domain has a connection error.
+   */
+  public boolean hasConnectionError()
+  {
+    if (broker != null)
+      return broker.hasConnectionError();
+    else
+      return true;
+  }
+
+  /**
    * Get the name of the replicationServer to which this domain is currently
    * connected.
    *

--
Gitblit v1.10.0