mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
ITS#5183 preliminary fix - this whole approach needs re-design
This commit is contained in:
parent
16460ccbde
commit
02f29d51c6
@ -174,7 +174,7 @@ typedef struct bdb_cache {
|
|||||||
#define BDB_INDICES 128
|
#define BDB_INDICES 128
|
||||||
|
|
||||||
struct bdb_db_info {
|
struct bdb_db_info {
|
||||||
char *bdi_name;
|
struct berval bdi_name;
|
||||||
DB *bdi_db;
|
DB *bdi_db;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ bdb_db_hash(
|
|||||||
int
|
int
|
||||||
bdb_db_cache(
|
bdb_db_cache(
|
||||||
Backend *be,
|
Backend *be,
|
||||||
const char *name,
|
struct berval *name,
|
||||||
DB **dbout )
|
DB **dbout )
|
||||||
{
|
{
|
||||||
int i, flags;
|
int i, flags;
|
||||||
@ -72,7 +72,7 @@ bdb_db_cache(
|
|||||||
*dbout = NULL;
|
*dbout = NULL;
|
||||||
|
|
||||||
for( i=BDB_NDB; i < bdb->bi_ndatabases; i++ ) {
|
for( i=BDB_NDB; i < bdb->bi_ndatabases; i++ ) {
|
||||||
if( !strcmp( bdb->bi_databases[i]->bdi_name, name) ) {
|
if( !ber_bvcmp( &bdb->bi_databases[i]->bdi_name, name) ) {
|
||||||
*dbout = bdb->bi_databases[i]->bdi_db;
|
*dbout = bdb->bi_databases[i]->bdi_db;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ bdb_db_cache(
|
|||||||
|
|
||||||
/* check again! may have been added by another thread */
|
/* check again! may have been added by another thread */
|
||||||
for( i=BDB_NDB; i < bdb->bi_ndatabases; i++ ) {
|
for( i=BDB_NDB; i < bdb->bi_ndatabases; i++ ) {
|
||||||
if( !strcmp( bdb->bi_databases[i]->bdi_name, name) ) {
|
if( !ber_bvcmp( &bdb->bi_databases[i]->bdi_name, name) ) {
|
||||||
*dbout = bdb->bi_databases[i]->bdi_db;
|
*dbout = bdb->bi_databases[i]->bdi_db;
|
||||||
ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
|
ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
|
||||||
return 0;
|
return 0;
|
||||||
@ -96,7 +96,7 @@ bdb_db_cache(
|
|||||||
|
|
||||||
db = (struct bdb_db_info *) ch_calloc(1, sizeof(struct bdb_db_info));
|
db = (struct bdb_db_info *) ch_calloc(1, sizeof(struct bdb_db_info));
|
||||||
|
|
||||||
db->bdi_name = ch_strdup( name );
|
ber_dupbv( &db->bdi_name, name );
|
||||||
|
|
||||||
rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 );
|
rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 );
|
||||||
if( rc != 0 ) {
|
if( rc != 0 ) {
|
||||||
@ -113,8 +113,9 @@ bdb_db_cache(
|
|||||||
#endif
|
#endif
|
||||||
rc = db->bdi_db->set_flags( db->bdi_db, DB_DUP | DB_DUPSORT );
|
rc = db->bdi_db->set_flags( db->bdi_db, DB_DUP | DB_DUPSORT );
|
||||||
|
|
||||||
file = ch_malloc( strlen( name ) + sizeof(BDB_SUFFIX) );
|
file = ch_malloc( db->bdi_name.bv_len + sizeof(BDB_SUFFIX) );
|
||||||
sprintf( file, "%s%s", name, BDB_SUFFIX );
|
strcpy( file, db->bdi_name.bv_val );
|
||||||
|
strcpy( file+db->bdi_name.bv_len, BDB_SUFFIX );
|
||||||
|
|
||||||
#ifdef HAVE_EBCDIC
|
#ifdef HAVE_EBCDIC
|
||||||
__atoe( file );
|
__atoe( file );
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
static char presence_keyval[LUTIL_HASH_BYTES] = {0,0,0,1};
|
static char presence_keyval[LUTIL_HASH_BYTES] = {0,0,0,1};
|
||||||
static struct berval presence_key = {LUTIL_HASH_BYTES, presence_keyval};
|
static struct berval presence_key = {LUTIL_HASH_BYTES, presence_keyval};
|
||||||
|
|
||||||
static AttrInfo *index_mask(
|
AttrInfo *bdb_index_mask(
|
||||||
Backend *be,
|
Backend *be,
|
||||||
AttributeDescription *desc,
|
AttributeDescription *desc,
|
||||||
struct berval *atname )
|
struct berval *atname )
|
||||||
@ -70,21 +70,6 @@ static AttrInfo *index_mask(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bdb_index_is_indexed(
|
|
||||||
Backend *be,
|
|
||||||
AttributeDescription *desc )
|
|
||||||
{
|
|
||||||
AttrInfo *ai;
|
|
||||||
struct berval prefix;
|
|
||||||
|
|
||||||
ai = index_mask( be, desc, &prefix );
|
|
||||||
|
|
||||||
if( !ai )
|
|
||||||
return LDAP_INAPPROPRIATE_MATCHING;
|
|
||||||
|
|
||||||
return LDAP_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This function is only called when evaluating search filters.
|
/* This function is only called when evaluating search filters.
|
||||||
*/
|
*/
|
||||||
int bdb_index_param(
|
int bdb_index_param(
|
||||||
@ -100,7 +85,7 @@ int bdb_index_param(
|
|||||||
slap_mask_t mask, type = 0;
|
slap_mask_t mask, type = 0;
|
||||||
DB *db;
|
DB *db;
|
||||||
|
|
||||||
ai = index_mask( be, desc, prefixp );
|
ai = bdb_index_mask( be, desc, prefixp );
|
||||||
|
|
||||||
if ( !ai ) {
|
if ( !ai ) {
|
||||||
#ifdef BDB_MONITOR_IDX
|
#ifdef BDB_MONITOR_IDX
|
||||||
@ -127,7 +112,7 @@ int bdb_index_param(
|
|||||||
}
|
}
|
||||||
mask = ai->ai_indexmask;
|
mask = ai->ai_indexmask;
|
||||||
|
|
||||||
rc = bdb_db_cache( be, prefixp->bv_val, &db );
|
rc = bdb_db_cache( be, prefixp, &db );
|
||||||
|
|
||||||
if( rc != LDAP_SUCCESS ) {
|
if( rc != LDAP_SUCCESS ) {
|
||||||
return rc;
|
return rc;
|
||||||
@ -200,7 +185,7 @@ static int indexer(
|
|||||||
|
|
||||||
assert( mask != 0 );
|
assert( mask != 0 );
|
||||||
|
|
||||||
rc = bdb_db_cache( op->o_bd, atname->bv_val, &db );
|
rc = bdb_db_cache( op->o_bd, atname, &db );
|
||||||
|
|
||||||
if ( rc != LDAP_SUCCESS ) {
|
if ( rc != LDAP_SUCCESS ) {
|
||||||
Debug( LDAP_DEBUG_ANY,
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
@ -30,13 +30,13 @@
|
|||||||
|
|
||||||
static const struct bdbi_database {
|
static const struct bdbi_database {
|
||||||
char *file;
|
char *file;
|
||||||
char *name;
|
struct berval name;
|
||||||
int type;
|
int type;
|
||||||
int flags;
|
int flags;
|
||||||
} bdbi_databases[] = {
|
} bdbi_databases[] = {
|
||||||
{ "id2entry" BDB_SUFFIX, "id2entry", DB_BTREE, 0 },
|
{ "id2entry" BDB_SUFFIX, BER_BVC("id2entry"), DB_BTREE, 0 },
|
||||||
{ "dn2id" BDB_SUFFIX, "dn2id", DB_BTREE, 0 },
|
{ "dn2id" BDB_SUFFIX, BER_BVC("dn2id"), DB_BTREE, 0 },
|
||||||
{ NULL, NULL, 0, 0 }
|
{ NULL, BER_BVNULL, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void * db_malloc(size_t);
|
typedef void * db_malloc(size_t);
|
||||||
@ -373,7 +373,7 @@ shm_retry:
|
|||||||
BDB_INDICES * sizeof(struct bdb_db_info *) );
|
BDB_INDICES * sizeof(struct bdb_db_info *) );
|
||||||
|
|
||||||
/* open (and create) main database */
|
/* open (and create) main database */
|
||||||
for( i = 0; bdbi_databases[i].name; i++ ) {
|
for( i = 0; bdbi_databases[i].name.bv_val; i++ ) {
|
||||||
struct bdb_db_info *db;
|
struct bdb_db_info *db;
|
||||||
|
|
||||||
db = (struct bdb_db_info *) ch_calloc(1, sizeof(struct bdb_db_info));
|
db = (struct bdb_db_info *) ch_calloc(1, sizeof(struct bdb_db_info));
|
||||||
@ -546,7 +546,7 @@ bdb_db_close( BackendDB *be, ConfigReply *cr )
|
|||||||
rc = db->bdi_db->close( db->bdi_db, 0 );
|
rc = db->bdi_db->close( db->bdi_db, 0 );
|
||||||
/* Lower numbered names are not strdup'd */
|
/* Lower numbered names are not strdup'd */
|
||||||
if( bdb->bi_ndatabases >= BDB_NDB )
|
if( bdb->bi_ndatabases >= BDB_NDB )
|
||||||
free( db->bdi_name );
|
free( db->bdi_name.bv_val );
|
||||||
free( db );
|
free( db );
|
||||||
}
|
}
|
||||||
free( bdb->bi_databases );
|
free( bdb->bi_databases );
|
||||||
|
@ -42,6 +42,9 @@ int bdb_modify_internal(
|
|||||||
Attribute *save_attrs;
|
Attribute *save_attrs;
|
||||||
Attribute *ap;
|
Attribute *ap;
|
||||||
int glue_attr_delete = 0;
|
int glue_attr_delete = 0;
|
||||||
|
int got_delete;
|
||||||
|
struct berval ix_at;
|
||||||
|
AttrInfo *ai;
|
||||||
|
|
||||||
Debug( LDAP_DEBUG_TRACE, "bdb_modify_internal: 0x%08lx: %s\n",
|
Debug( LDAP_DEBUG_TRACE, "bdb_modify_internal: 0x%08lx: %s\n",
|
||||||
e->e_id, e->e_dn, 0);
|
e->e_id, e->e_dn, 0);
|
||||||
@ -88,6 +91,7 @@ int bdb_modify_internal(
|
|||||||
|
|
||||||
for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
|
for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
|
||||||
mod = &ml->sml_mod;
|
mod = &ml->sml_mod;
|
||||||
|
got_delete = 0;
|
||||||
|
|
||||||
switch ( mod->sm_op ) {
|
switch ( mod->sm_op ) {
|
||||||
case LDAP_MOD_ADD:
|
case LDAP_MOD_ADD:
|
||||||
@ -117,6 +121,8 @@ int bdb_modify_internal(
|
|||||||
if( err != LDAP_SUCCESS ) {
|
if( err != LDAP_SUCCESS ) {
|
||||||
Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
|
Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
|
||||||
err, *text, 0);
|
err, *text, 0);
|
||||||
|
} else {
|
||||||
|
got_delete = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -129,6 +135,8 @@ int bdb_modify_internal(
|
|||||||
if( err != LDAP_SUCCESS ) {
|
if( err != LDAP_SUCCESS ) {
|
||||||
Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
|
Debug(LDAP_DEBUG_ARGS, "bdb_modify_internal: %d %s\n",
|
||||||
err, *text, 0);
|
err, *text, 0);
|
||||||
|
} else {
|
||||||
|
got_delete = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -142,6 +150,8 @@ int bdb_modify_internal(
|
|||||||
Debug(LDAP_DEBUG_ARGS,
|
Debug(LDAP_DEBUG_ARGS,
|
||||||
"bdb_modify_internal: %d %s\n",
|
"bdb_modify_internal: %d %s\n",
|
||||||
err, *text, 0);
|
err, *text, 0);
|
||||||
|
} else {
|
||||||
|
got_delete = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -194,13 +204,24 @@ int bdb_modify_internal(
|
|||||||
|
|
||||||
/* check if modified attribute was indexed
|
/* check if modified attribute was indexed
|
||||||
* but not in case of NOOP... */
|
* but not in case of NOOP... */
|
||||||
err = bdb_index_is_indexed( op->o_bd, mod->sm_desc );
|
ai = bdb_index_mask( op->o_bd, mod->sm_desc, &ix_at );
|
||||||
if ( err == LDAP_SUCCESS && !op->o_noop ) {
|
if ( ai && !op->o_noop ) {
|
||||||
ap = attr_find( save_attrs, mod->sm_desc );
|
if ( got_delete ) {
|
||||||
if ( ap ) ap->a_flags |= SLAP_ATTR_IXDEL;
|
struct berval ix2;
|
||||||
|
|
||||||
ap = attr_find( e->e_attrs, mod->sm_desc );
|
ap = attr_find( save_attrs, mod->sm_desc );
|
||||||
if ( ap ) ap->a_flags |= SLAP_ATTR_IXADD;
|
if ( ap ) ap->a_flags |= SLAP_ATTR_IXDEL;
|
||||||
|
|
||||||
|
/* Find all other attrs that index to same slot */
|
||||||
|
for ( ap = e->e_attrs; ap; ap=ap->a_next ) {
|
||||||
|
ai = bdb_index_mask( op->o_bd, ap->a_desc, &ix2 );
|
||||||
|
if ( ai && ix2.bv_val == ix_at.bv_val )
|
||||||
|
ap->a_flags |= SLAP_ATTR_IXADD;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ap = attr_find( e->e_attrs, mod->sm_desc );
|
||||||
|
if ( ap ) ap->a_flags |= SLAP_ATTR_IXADD;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ int bdb_back_init_cf( BackendInfo *bi );
|
|||||||
int
|
int
|
||||||
bdb_db_cache(
|
bdb_db_cache(
|
||||||
Backend *be,
|
Backend *be,
|
||||||
const char *name,
|
struct berval *name,
|
||||||
DB **db );
|
DB **db );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -328,7 +328,7 @@ int bdb_idl_append_one( ID *ids, ID id );
|
|||||||
/*
|
/*
|
||||||
* index.c
|
* index.c
|
||||||
*/
|
*/
|
||||||
#define bdb_index_is_indexed BDB_SYMBOL(index_is_indexed)
|
#define bdb_index_mask BDB_SYMBOL(index_mask)
|
||||||
#define bdb_index_param BDB_SYMBOL(index_param)
|
#define bdb_index_param BDB_SYMBOL(index_param)
|
||||||
#define bdb_index_values BDB_SYMBOL(index_values)
|
#define bdb_index_values BDB_SYMBOL(index_values)
|
||||||
#define bdb_index_entry BDB_SYMBOL(index_entry)
|
#define bdb_index_entry BDB_SYMBOL(index_entry)
|
||||||
@ -336,9 +336,10 @@ int bdb_idl_append_one( ID *ids, ID id );
|
|||||||
#define bdb_index_recrun BDB_SYMBOL(index_recrun)
|
#define bdb_index_recrun BDB_SYMBOL(index_recrun)
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
bdb_index_is_indexed LDAP_P((
|
bdb_index_mask LDAP_P((
|
||||||
Backend *be,
|
Backend *be,
|
||||||
AttributeDescription *desc ));
|
AttributeDescription *desc,
|
||||||
|
struct berval *name ));
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
bdb_index_param LDAP_P((
|
bdb_index_param LDAP_P((
|
||||||
|
Loading…
Reference in New Issue
Block a user