From 111e11ad2b8ef1f3a1827e0aa833512189424a8b Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Jun 26 2014 14:31:08 +0000 Subject: Ticket #47831 - server restart wipes out index config if there is a default index https://fedorahosted.org/389/ticket/47831 Reviewed by: nhosoi (Thanks!) Branch: 389-ds-base-1.3.2 Fix Description: In ldbm_instance_index_config_enable_index(), only call the function ldbm_index_parse_entry() if the index does not exist. Instead, get the name of the index from the "cn" attribute of the entry, and use ainfo_get() to get the index. If this returns NULL, then call ldbm_index_parse_entry() to create and parse the index. Platforms tested: Fedora 20 Flag Day: no Doc impact: no (cherry picked from commit 5c5c9603946ecb89fb17df665a95aa3ce75e01de) --- diff --git a/ldap/servers/slapd/back-ldbm/ldbm_index_config.c b/ldap/servers/slapd/back-ldbm/ldbm_index_config.c index e2bec79..51801f5 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_index_config.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_index_config.c @@ -347,19 +347,26 @@ int ldbm_instance_config_add_index_entry( int ldbm_instance_index_config_enable_index(ldbm_instance *inst, Slapi_Entry* e) { - char *index_name; - int rc; + char *index_name = NULL; + int rc = LDAP_SUCCESS; + struct attrinfo *ai = NULL; - rc=ldbm_index_parse_entry(inst, e, "from DSE add", &index_name); + index_name = slapi_entry_attr_get_charptr(e, "cn"); + if (index_name) { + ainfo_get(inst->inst_be, index_name, &ai); + } + if (!ai) { + rc=ldbm_index_parse_entry(inst, e, "from DSE add", &index_name); + } if (rc == LDAP_SUCCESS) { /* Assume the caller knows if it is OK to go online immediately */ - struct attrinfo *ai = NULL; - - ainfo_get(inst->inst_be, index_name, &ai); + if (!ai) { + ainfo_get(inst->inst_be, index_name, &ai); + } PR_ASSERT(ai != NULL); ai->ai_indexmask &= ~INDEX_OFFLINE; - slapi_ch_free((void **)&index_name); - } + } + slapi_ch_free_string(&index_name); return rc; }