Blame SOURCES/0073-Ticket-49180-backport-1.3.6-errors-log-filled-with-a.patch

6f51e1
From 1787e9ffda09f9ec8518ceaede5cf1ef014c5d17 Mon Sep 17 00:00:00 2001
40cd75
From: Ludwig Krispenz <lkrispen@redhat.com>
6f51e1
Date: Wed, 27 Sep 2017 10:58:36 +0200
6f51e1
Subject: [PATCH] Ticket: 49180 - backport 1.3.6 errors log filled with
6f51e1
 attrlist_replace - attr_replace
40cd75
6f51e1
    Bug: If a RUV contains the same URL with different replica IDs the created referrals contain duplicates
40cd75
6f51e1
    Fix: check duplicate referrals
40cd75
6f51e1
    Reviewed by: Mark, thanks
40cd75
---
40cd75
 ldap/servers/plugins/replication/repl5_ruv.c | 13 ++++++++++++-
40cd75
 1 file changed, 12 insertions(+), 1 deletion(-)
40cd75
40cd75
diff --git a/ldap/servers/plugins/replication/repl5_ruv.c b/ldap/servers/plugins/replication/repl5_ruv.c
6f51e1
index 39449b6..7f34059 100644
40cd75
--- a/ldap/servers/plugins/replication/repl5_ruv.c
40cd75
+++ b/ldap/servers/plugins/replication/repl5_ruv.c
6f51e1
@@ -1502,7 +1502,17 @@ ruv_replica_count (const RUV *ruv)
40cd75
  * Extract all the referral URL's from the RUV (but self URL),
40cd75
  * returning them in an array of strings, that
40cd75
  * the caller must free.
40cd75
+ * We also check and remove duplicates (caused by unclean RUVs)
40cd75
  */
40cd75
+static int
40cd75
+ruv_referral_exists(unsigned char *purl, char **refs, int count)
40cd75
+{
40cd75
+    for (size_t j=0; j
40cd75
+        if (0 == slapi_utf8casecmp(purl, (unsigned char *)refs[j]))
40cd75
+            return 1;
40cd75
+    }
40cd75
+    return 0;
40cd75
+}
40cd75
 char **
40cd75
 ruv_get_referrals(const RUV *ruv)
40cd75
 {
6f51e1
@@ -1525,7 +1535,8 @@ ruv_get_referrals(const RUV *ruv)
6f51e1
 			/* Add URL into referrals if doesn't match self URL */
6f51e1
 			if((replica->replica_purl!=NULL) &&
6f51e1
 			   (slapi_utf8casecmp((unsigned char *)replica->replica_purl,
6f51e1
-								  (unsigned char *)mypurl) != 0))
40cd75
+                                   (unsigned char *)mypurl) != 0) &&
6f51e1
+			    !ruv_referral_exists((unsigned char *)replica->replica_purl, r, i))
6f51e1
 			{
6f51e1
 		 		r[i]= slapi_ch_strdup(replica->replica_purl);
6f51e1
 				i++;
40cd75
-- 
6f51e1
2.9.5
40cd75