andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
40cd75
From 1787e9ffda09f9ec8518ceaede5cf1ef014c5d17 Mon Sep 17 00:00:00 2001
40cd75
From: Ludwig Krispenz <lkrispen@redhat.com>
40cd75
Date: Wed, 27 Sep 2017 10:58:36 +0200
40cd75
Subject: [PATCH] Ticket: 49180 - backport 1.3.6 errors log filled with
40cd75
 attrlist_replace - attr_replace
40cd75
40cd75
    Bug: If a RUV contains the same URL with different replica IDs the created referrals contain duplicates
40cd75
40cd75
    Fix: check duplicate referrals
40cd75
40cd75
    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
40cd75
index 39449b6..7f34059 100644
40cd75
--- a/ldap/servers/plugins/replication/repl5_ruv.c
40cd75
+++ b/ldap/servers/plugins/replication/repl5_ruv.c
40cd75
@@ -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
 {
40cd75
@@ -1525,7 +1535,8 @@ ruv_get_referrals(const RUV *ruv)
40cd75
 			/* Add URL into referrals if doesn't match self URL */
40cd75
 			if((replica->replica_purl!=NULL) &&
40cd75
 			   (slapi_utf8casecmp((unsigned char *)replica->replica_purl,
40cd75
-								  (unsigned char *)mypurl) != 0))
40cd75
+                                   (unsigned char *)mypurl) != 0) &&
40cd75
+			    !ruv_referral_exists((unsigned char *)replica->replica_purl, r, i))
40cd75
 			{
40cd75
 		 		r[i]= slapi_ch_strdup(replica->replica_purl);
40cd75
 				i++;
40cd75
-- 
40cd75
2.9.5
40cd75