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

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