andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From 2b5955c907f747a44a460c35eee76df9de03a3db Mon Sep 17 00:00:00 2001
dc8c34
From: Rich Megginson <rmeggins@redhat.com>
dc8c34
Date: Wed, 25 Jun 2014 16:49:50 -0600
dc8c34
Subject: [PATCH 230/234] Ticket #47831 - server restart wipes out index config
dc8c34
 if there is a default index
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/47831
dc8c34
Reviewed by: nhosoi (Thanks!)
dc8c34
Branch: 389-ds-base-1.2.11
dc8c34
Fix Description: In ldbm_instance_index_config_enable_index(), only call
dc8c34
the function ldbm_index_parse_entry() if the index does not exist.  Instead,
dc8c34
get the name of the index from the "cn" attribute of the entry, and use
dc8c34
ainfo_get() to get the index.  If this returns NULL, then call
dc8c34
ldbm_index_parse_entry() to create and parse the index.
dc8c34
Platforms tested: Fedora 20
dc8c34
Flag Day: no
dc8c34
Doc impact: no
dc8c34
dc8c34
(cherry picked from commit 5c5c9603946ecb89fb17df665a95aa3ce75e01de)
dc8c34
(cherry picked from commit 111e11ad2b8ef1f3a1827e0aa833512189424a8b)
dc8c34
(cherry picked from commit 18bc3e82c3919867f14747343e452019630b60d0)
dc8c34
(cherry picked from commit e260d9fd9e680579677007b6466f4e9ad3323eb6)
dc8c34
(cherry picked from commit 4bccd2b735d1fc6765f37623f8f67d6c2f22226d)
dc8c34
---
dc8c34
 ldap/servers/slapd/back-ldbm/ldbm_index_config.c | 23 +++++++++++++++--------
dc8c34
 1 file changed, 15 insertions(+), 8 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_index_config.c b/ldap/servers/slapd/back-ldbm/ldbm_index_config.c
dc8c34
index 2775785..7026a79 100644
dc8c34
--- a/ldap/servers/slapd/back-ldbm/ldbm_index_config.c
dc8c34
+++ b/ldap/servers/slapd/back-ldbm/ldbm_index_config.c
dc8c34
@@ -341,19 +341,26 @@ int ldbm_instance_config_add_index_entry(
dc8c34
 int
dc8c34
 ldbm_instance_index_config_enable_index(ldbm_instance *inst, Slapi_Entry* e)
dc8c34
 {
dc8c34
-    char *index_name;
dc8c34
-    int rc;
dc8c34
+    char *index_name = NULL;
dc8c34
+    int rc = LDAP_SUCCESS;
dc8c34
+    struct attrinfo *ai = NULL;
dc8c34
 
dc8c34
-    rc=ldbm_index_parse_entry(inst, e, "from DSE add", &index_name);
dc8c34
+    index_name = slapi_entry_attr_get_charptr(e, "cn");
dc8c34
+    if (index_name) {
dc8c34
+        ainfo_get(inst->inst_be, index_name, &ai;;
dc8c34
+    }
dc8c34
+    if (!ai) {
dc8c34
+        rc=ldbm_index_parse_entry(inst, e, "from DSE add", &index_name);
dc8c34
+    }
dc8c34
     if (rc == LDAP_SUCCESS) {
dc8c34
     	/* Assume the caller knows if it is OK to go online immediately */
dc8c34
-        struct attrinfo *ai = NULL;
dc8c34
-
dc8c34
-        ainfo_get(inst->inst_be, index_name, &ai;;
dc8c34
+        if (!ai) {
dc8c34
+            ainfo_get(inst->inst_be, index_name, &ai;;
dc8c34
+        }
dc8c34
         PR_ASSERT(ai != NULL);
dc8c34
         ai->ai_indexmask &= ~INDEX_OFFLINE;
dc8c34
-        slapi_ch_free((void **)&index_name);
dc8c34
-    } 
dc8c34
+    }
dc8c34
+    slapi_ch_free_string(&index_name);
dc8c34
     return rc;
dc8c34
 }
dc8c34
 
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34