mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-01 04:29:35 -05:00
filter_candidate tweaks, search_stack tweaks
This commit is contained in:
parent
f97a85db83
commit
7c39a5e726
4 changed files with 41 additions and 12 deletions
|
|
@ -417,6 +417,7 @@ bdb_dn2idl(
|
|||
struct berval *dn,
|
||||
int prefix,
|
||||
ID *ids,
|
||||
ID *stack,
|
||||
void *ctx )
|
||||
{
|
||||
int rc;
|
||||
|
|
@ -871,7 +872,9 @@ struct dn2id_cookie {
|
|||
ID id;
|
||||
ID dbuf;
|
||||
ID *ids;
|
||||
void *ptr;
|
||||
ID tmp[BDB_IDL_DB_SIZE];
|
||||
ID *buf;
|
||||
DBT key;
|
||||
DBT data;
|
||||
DBC *dbc;
|
||||
|
|
@ -900,15 +903,33 @@ bdb_dn2idl_internal(
|
|||
if ( cx->rc ) return cx->rc;
|
||||
BDB_IDL_ZERO( cx->tmp );
|
||||
|
||||
cx->data.data = &cx->dbuf;
|
||||
cx->data.ulen = sizeof(ID);
|
||||
cx->data.dlen = sizeof(ID);
|
||||
cx->data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
|
||||
|
||||
/* The first item holds the parent ID. Ignore it. */
|
||||
cx->rc = cx->dbc->c_get( cx->dbc, &cx->key, &cx->data, DB_SET );
|
||||
if ( cx->rc == DB_NOTFOUND ) goto saveit;
|
||||
if ( cx->rc ) return cx->rc;
|
||||
|
||||
cx->data.data = cx->buf;
|
||||
cx->data.ulen = BDB_IDL_UM_SIZE * sizeof(ID);
|
||||
cx->data.flags = DB_DBT_USERMEM;
|
||||
|
||||
/* Fetch the rest of the IDs in a loop... */
|
||||
while ( (cx->rc = cx->dbc->c_get( cx->dbc, &cx->key, &cx->data,
|
||||
DB_NEXT_DUP )) == 0 ) {
|
||||
bdb_idl_insert( cx->tmp, cx->dbuf );
|
||||
DB_MULTIPLE | DB_NEXT_DUP )) == 0 ) {
|
||||
u_int8_t *j;
|
||||
size_t len;
|
||||
DB_MULTIPLE_INIT( cx->ptr, &cx->data );
|
||||
while (cx->ptr) {
|
||||
DB_MULTIPLE_NEXT( cx->ptr, &cx->data, j, len );
|
||||
if (j) {
|
||||
AC_MEMCPY( &cx->dbuf, j, sizeof(ID) );
|
||||
bdb_idl_insert( cx->tmp, cx->dbuf );
|
||||
}
|
||||
}
|
||||
}
|
||||
cx->dbc->c_close( cx->dbc );
|
||||
|
||||
|
|
@ -952,16 +973,26 @@ bdb_dn2idl(
|
|||
struct berval *dn,
|
||||
int prefix,
|
||||
ID *ids,
|
||||
ID *stack,
|
||||
void *ctx )
|
||||
{
|
||||
struct dn2id_cookie cx;
|
||||
EntryInfo *ei = (EntryInfo *)dn;
|
||||
|
||||
cx.id = *(ID *)dn;
|
||||
#ifndef BDB_MULTIPLE_SUFFIXES
|
||||
if ( ei->bei_parent->bei_id == 0 ) {
|
||||
struct bdb_info *bdb = (struct bdb_info *)be->be_private;
|
||||
BDB_IDL_ALL( bdb, ids );
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
cx.id = ei->bei_id;
|
||||
cx.bdb = (struct bdb_info *)be->be_private;
|
||||
cx.db = cx.bdb->bi_dn2id->bdi_db;
|
||||
cx.prefix = prefix;
|
||||
cx.ids = ids;
|
||||
cx.buf = stack;
|
||||
cx.ctx = ctx;
|
||||
|
||||
BDB_IDL_ZERO( ids );
|
||||
|
|
@ -976,10 +1007,6 @@ bdb_dn2idl(
|
|||
cx.key.flags = DB_DBT_USERMEM;
|
||||
|
||||
DBTzero(&cx.data);
|
||||
cx.data.data = &cx.dbuf;
|
||||
cx.data.ulen = sizeof(ID);
|
||||
cx.data.dlen = sizeof(ID);
|
||||
cx.data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
|
||||
|
||||
return bdb_dn2idl_internal(&cx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ bdb_filter_candidates(
|
|||
Debug( LDAP_DEBUG_FILTER, "\tDN ONE\n", 0, 0, 0 );
|
||||
#endif
|
||||
rc = bdb_dn2idl( op->o_bd, f->f_dn, DN_ONE_PREFIX, ids,
|
||||
op->o_tmpmemctx );
|
||||
stack, op->o_tmpmemctx );
|
||||
if( rc == DB_NOTFOUND ) {
|
||||
BDB_IDL_ZERO( ids );
|
||||
rc = 0;
|
||||
|
|
@ -82,7 +82,7 @@ bdb_filter_candidates(
|
|||
Debug( LDAP_DEBUG_FILTER, "\tDN SUBTREE\n", 0, 0, 0 );
|
||||
#endif
|
||||
rc = bdb_dn2idl( op->o_bd, f->f_dn, DN_SUBTREE_PREFIX, ids,
|
||||
op->o_tmpmemctx );
|
||||
stack, op->o_tmpmemctx );
|
||||
break;
|
||||
|
||||
case LDAP_FILTER_PRESENT:
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ bdb_dn2idl(
|
|||
struct berval *dn,
|
||||
int prefix,
|
||||
ID *ids,
|
||||
ID *stack,
|
||||
void *ctx );
|
||||
|
||||
#ifdef BDB_HIER
|
||||
|
|
|
|||
|
|
@ -268,16 +268,16 @@ nextido:
|
|||
* we should never see the ID of an entry that doesn't exist.
|
||||
* Set the name so that the scope's IDL can be retrieved.
|
||||
*/
|
||||
#ifndef BDB_HIER
|
||||
ei = NULL;
|
||||
rs->sr_err = bdb_cache_find_entry_id(op->o_bd, NULL, ido, &ei,
|
||||
0, locker, &locka, op->o_tmpmemctx );
|
||||
if (rs->sr_err != LDAP_SUCCESS) goto nextido;
|
||||
e = ei->bei_e;
|
||||
#ifndef BDB_HIER
|
||||
sf->f_dn = &e->e_nname;
|
||||
#else
|
||||
/* bdb_dn2idl uses IDs for keys, not DNs */
|
||||
sf->f_dn = (struct berval *)&ido;
|
||||
sf->f_dn = (struct berval *)ei;
|
||||
#endif
|
||||
}
|
||||
return rs->sr_err;
|
||||
|
|
@ -662,6 +662,7 @@ dn2entry_retry:
|
|||
/* Copy info to base, must free entry before accessing the database
|
||||
* in search_candidates, to avoid deadlocks.
|
||||
*/
|
||||
base.e_private = e->e_private;
|
||||
base.e_nname = realbase;
|
||||
base.e_id = e->e_id;
|
||||
|
||||
|
|
@ -1520,7 +1521,7 @@ static int search_candidates(
|
|||
? SLAPD_FILTER_DN_SUBTREE
|
||||
: SLAPD_FILTER_DN_ONE;
|
||||
#ifdef BDB_HIER
|
||||
scopef.f_dn = (struct berval *)&e->e_id;
|
||||
scopef.f_dn = (struct berval *)e->e_private;
|
||||
#else
|
||||
scopef.f_dn = &e->e_nname;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue