Blame SOURCES/0003-Ticket-49180-errors-log-filled-with-attrlist_replace.patch

081b2d
From 62fbb3423b26426e735e134134ab710945514ca6 Mon Sep 17 00:00:00 2001
40cd75
From: Ludwig Krispenz <lkrispen@redhat.com>
081b2d
Date: Tue, 26 Sep 2017 15:51:41 +0200
081b2d
Subject: [PATCH] Ticket: 49180 - errors log filled with attrlist_replace -
081b2d
 attr_replace
40cd75
081b2d
Bug: If a RUV contains the same URL with different replica IDs the created referrals contain duplicates
40cd75
081b2d
Fix: check duplicate referrals
40cd75
081b2d
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
081b2d
index 40dc0928b..7bfdc3425 100644
40cd75
--- a/ldap/servers/plugins/replication/repl5_ruv.c
40cd75
+++ b/ldap/servers/plugins/replication/repl5_ruv.c
081b2d
@@ -1386,7 +1386,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
 {
081b2d
@@ -1407,7 +1417,8 @@ ruv_get_referrals(const RUV *ruv)
081b2d
             /* Add URL into referrals if doesn't match self URL */
081b2d
             if ((replica->replica_purl != NULL) &&
081b2d
                 (slapi_utf8casecmp((unsigned char *)replica->replica_purl,
081b2d
-                                   (unsigned char *)mypurl) != 0)) {
40cd75
+                                   (unsigned char *)mypurl) != 0) &&
081b2d
+                !ruv_referral_exists((unsigned char *)replica->replica_purl, r, i)) {
081b2d
                 r[i] = slapi_ch_strdup(replica->replica_purl);
081b2d
                 i++;
081b2d
             }
40cd75
-- 
081b2d
2.13.6
40cd75