From: Howard Chu Date: Sun, 24 Dec 2006 03:44:08 +0000 (+0000) Subject: ITS#4337 insert EntryInfo in proper slot X-Git-Tag: OPENLDAP_REL_ENG_2_4_4ALPHA~8^2~321 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=58886b6a9c7c6b8e9e829fe24fe057e5a77b6117;p=openldap ITS#4337 insert EntryInfo in proper slot --- diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 366228d1bc..4ff1d3b954 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -4195,11 +4195,37 @@ ok: if ( !last ) { cfb->cb_root = ce; } else if ( last->ce_kids ) { - CfEntryInfo *c2; + CfEntryInfo *c2, **cprev; - for (c2=last->ce_kids; c2 && c2->ce_sibs; c2 = c2->ce_sibs); - - c2->ce_sibs = ce; + /* Advance to first of this type */ + cprev = &last->ce_kids; + for ( c2 = *cprev; c2 && c2->ce_type != ce->ce_type; ) { + cprev = &c2->ce_sibs; + c2 = c2->ce_sibs; + } + /* Account for the (-1) frontendDB entry */ + if ( ce->ce_type == Cft_Database ) { + if ( ca->be == frontendDB ) + ibase = 0; + else if ( ibase != -1 ) + ibase++; + } + /* Append */ + if ( ibase < 0 ) { + for (c2 = *cprev; c2 && c2->ce_type == ce->ce_type;) { + cprev = &c2->ce_sibs; + c2 = c2->ce_sibs; + } + } else { + /* Insert */ + int i; + for ( i=0; ice_sibs; + } + } + ce->ce_sibs = *cprev; + *cprev = ce; } else { last->ce_kids = ce; }