From: Howard Chu Date: Sat, 12 Jun 2004 07:39:24 +0000 (+0000) Subject: Better fix for ITS#3063, #3186 X-Git-Tag: OPENDLAP_REL_ENG_2_2_MP~287 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7c7754b95626428d5205a84a53691467fb6abd42;p=openldap Better fix for ITS#3063, #3186 --- diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 22da9a6a37..476043febe 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -380,38 +380,6 @@ retry: /* transaction retry */ goto return_results; } - /* This is the first add to a root DB, need to make the suffix glue */ - if ( op->o_bd->be_nsuffix[0].bv_len == 0 && ei->bei_id == 0 ) { - Entry e_root = {0}; - e_root.e_name.bv_val = ""; - e_root.e_nname.bv_val = ""; - e_root.e_id = 1; - rs->sr_err = bdb_dn2id_add( op, lt2, ei, &e_root ); - - /* Just give up on any failure. */ - if ( rs->sr_err ) { - rs->sr_err = LDAP_OTHER; - goto return_results; - } - - /* Get a new ID for the actual entry */ - if ( op->oq_add.rs_e->e_id == 1 ) { - rs->sr_err = bdb_next_id( op->o_bd, NULL, &op->oq_add.rs_e->e_id ); - if (rs->sr_err) { - rs->sr_err = LDAP_OTHER; - goto return_results; - } - } - - /* Get new EntryInfo */ - rs->sr_err = bdb_dn2entry( op, ltid, &op->ora_e->e_nname, &ei, - 1, locker, &lock ); - if (rs->sr_err != DB_NOTFOUND) { - rs->sr_err = LDAP_OTHER; - goto return_results; - } - } - /* dn2id index */ rs->sr_err = bdb_dn2id_add( op, lt2, ei, op->oq_add.rs_e ); if ( rs->sr_err != 0 ) { diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index d6dd366165..e1fcc9812e 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -290,6 +290,16 @@ bdb_cache_find_ndn( ptr = ndn->bv_val + ndn->bv_len - op->o_bd->be_nsuffix[0].bv_len; ei.bei_nrdn.bv_val = ptr; ei.bei_nrdn.bv_len = op->o_bd->be_nsuffix[0].bv_len; + /* Skip to next rdn if suffix is empty */ + if ( ei.bei_nrdn.bv_len == 0 ) { + for (ptr = ei.bei_nrdn.bv_val - 2; ptr > ndn->bv_val + && !DN_SEPARATOR(*ptr); ptr--) /* empty */; + if ( ptr >= ndn->bv_val ) { + if (DN_SEPARATOR(*ptr)) ptr++; + ei.bei_nrdn.bv_len = ei.bei_nrdn.bv_val - ptr; + ei.bei_nrdn.bv_val = ptr; + } + } eip = &bdb->bi_cache.c_dntree; } diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index b42b9b406e..7a91c99c0b 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -524,7 +524,7 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop, ei_root.bei_e = &e_root; ei_root.bei_parent = &ei_root; e_root.e_private = &ei_root; - e_root.e_id = 1; + e_root.e_id = 0; e_root.e_nname.bv_val=""; e_root.e_name.bv_val=""; ei = &ei_root; @@ -988,7 +988,7 @@ id2entry_retry: #endif case LDAP_SCOPE_SUBTREE: { EntryInfo *tmp; - for (tmp = BEI(e); tmp->bei_parent; + for (tmp = BEI(e); tmp; tmp = tmp->bei_parent ) { if ( tmp->bei_id == base.e_id ) { scopeok = 1; diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index 0ae213d032..6484e4db9e 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -68,19 +68,12 @@ int bdb_tool_entry_close( if( nholes ) { unsigned i; - int fail=0, warn=1; + fprintf( stderr, "Error, entries missing!\n"); for (i=0; io_bd->be_private; - struct berval dn = e->e_nname; - struct berval pdn; + struct berval dn = e->e_name; + struct berval ndn = e->e_nname; + struct berval pdn, npdn; EntryInfo *ei = NULL; int rc; - rc = bdb_cache_find_ndn( op, tid, &dn, &ei ); + if (ndn.bv_len == 0) return 0; + + rc = bdb_cache_find_ndn( op, tid, &ndn, &ei ); if ( ei ) bdb_cache_entryinfo_unlock( ei ); if ( rc == DB_NOTFOUND ) { - if ( be_issuffix( op->o_bd, &dn ) ) { - pdn = slap_empty_bv; - } else { + if ( !be_issuffix( op->o_bd, &ndn ) ) { dnParent( &dn, &pdn ); - e->e_nname = pdn; + dnParent( &ndn, &npdn ); + e->e_name = pdn; + e->e_nname = npdn; rc = bdb_tool_next_id( op, tid, e, text, 1 ); - e->e_nname = dn; + e->e_name = dn; + e->e_nname = ndn; if ( rc ) { return rc; } @@ -266,7 +263,7 @@ static int bdb_tool_next_id( } nhmax *= 2; } - ber_dupbv( &holes[nholes].dn, &dn ); + ber_dupbv( &holes[nholes].dn, &ndn ); holes[nholes++].id = e->e_id; } } else if ( !hole ) {