andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

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

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