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

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