mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
Misc code cleanup
This commit is contained in:
parent
323689da57
commit
d5d801d152
@ -69,17 +69,17 @@ retry: rc = txn_abort( ltid );
|
||||
}
|
||||
|
||||
/* begin transaction */
|
||||
if (bdb->bi_txn) {
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_add: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
if( bdb->bi_txn ) {
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_add: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
}
|
||||
|
||||
opinfo.boi_bdb = be;
|
||||
@ -275,8 +275,9 @@ retry: rc = txn_abort( ltid );
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
if( bdb->bi_txn )
|
||||
if( bdb->bi_txn ) {
|
||||
rc = txn_commit( ltid, 0 );
|
||||
}
|
||||
ltid = NULL;
|
||||
op->o_private = NULL;
|
||||
|
||||
|
@ -24,7 +24,7 @@ typedef struct bdb_attrinfo {
|
||||
static int
|
||||
ainfo_type_cmp(
|
||||
AttributeDescription *desc,
|
||||
AttrInfo *a
|
||||
AttrInfo *a
|
||||
)
|
||||
{
|
||||
return desc - a->ai_desc;
|
||||
@ -32,8 +32,8 @@ ainfo_type_cmp(
|
||||
|
||||
static int
|
||||
ainfo_cmp(
|
||||
AttrInfo *a,
|
||||
AttrInfo *b
|
||||
AttrInfo *a,
|
||||
AttrInfo *b
|
||||
)
|
||||
{
|
||||
return a->ai_desc - b->ai_desc;
|
||||
@ -41,25 +41,25 @@ ainfo_cmp(
|
||||
|
||||
void
|
||||
bdb_attr_mask(
|
||||
struct bdb_info *bdb,
|
||||
AttributeDescription *desc,
|
||||
slap_mask_t *indexmask )
|
||||
struct bdb_info *bdb,
|
||||
AttributeDescription *desc,
|
||||
slap_mask_t *indexmask )
|
||||
{
|
||||
AttrInfo *a;
|
||||
|
||||
a = (AttrInfo *) avl_find( bdb->bi_attrs, desc,
|
||||
(AVL_CMP) ainfo_type_cmp );
|
||||
(AVL_CMP) ainfo_type_cmp );
|
||||
|
||||
*indexmask = a != NULL ? a->ai_indexmask : 0;
|
||||
}
|
||||
|
||||
int
|
||||
bdb_attr_index_config(
|
||||
struct bdb_info *bdb,
|
||||
const char *fname,
|
||||
int lineno,
|
||||
int argc,
|
||||
char **argv )
|
||||
struct bdb_info *bdb,
|
||||
const char *fname,
|
||||
int lineno,
|
||||
int argc,
|
||||
char **argv )
|
||||
{
|
||||
int rc;
|
||||
int i;
|
||||
@ -108,7 +108,7 @@ bdb_attr_index_config(
|
||||
}
|
||||
}
|
||||
|
||||
if( !mask ) {
|
||||
if( !mask ) {
|
||||
fprintf( stderr, "%s: line %d: "
|
||||
"no indexes selected\n",
|
||||
fname, lineno );
|
||||
@ -182,8 +182,8 @@ bdb_attr_index_config(
|
||||
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
|
||||
"attr_index_config: index %s 0x%04x\n",
|
||||
ad->ad_cname.bv_val, mask ));
|
||||
"attr_index_config: index %s 0x%04x\n",
|
||||
ad->ad_cname.bv_val, mask ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_CONFIG, "index %s 0x%04x\n",
|
||||
ad->ad_cname.bv_val, mask, 0 );
|
||||
@ -199,7 +199,7 @@ bdb_attr_index_config(
|
||||
if( rc ) {
|
||||
fprintf( stderr, "%s: line %d: duplicate index definition "
|
||||
"for attr \"%s\" (ignored)\n",
|
||||
fname, lineno, attrs[i] );
|
||||
fname, lineno, attrs[i] );
|
||||
|
||||
return LDAP_PARAM_ERROR;
|
||||
}
|
||||
|
@ -25,26 +25,26 @@ bdb_attribute(
|
||||
Backend *be,
|
||||
Connection *conn,
|
||||
Operation *op,
|
||||
Entry *target,
|
||||
const char *e_ndn,
|
||||
Entry *target,
|
||||
const char *e_ndn,
|
||||
AttributeDescription *entry_at,
|
||||
struct berval ***vals )
|
||||
{
|
||||
struct bdbinfo *li = (struct bdbinfo *) be->be_private;
|
||||
Entry *e;
|
||||
int i, j, rc;
|
||||
Attribute *attr;
|
||||
struct bdbinfo *li = (struct bdbinfo *) be->be_private;
|
||||
Entry *e;
|
||||
int i, j, rc;
|
||||
Attribute *attr;
|
||||
struct berval **v;
|
||||
const char *entry_at_name = entry_at->ad_cname.bv_val;
|
||||
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_ARGS,
|
||||
"bdb_attribute: gr dn: \"%s\"\n", e_ndn ));
|
||||
"bdb_attribute: gr dn: \"%s\"\n", e_ndn ));
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_ARGS,
|
||||
"bdb_attribute: at: \"%s\"\n", entry_at_name));
|
||||
"bdb_attribute: at: \"%s\"\n", entry_at_name));
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_ARGS,
|
||||
"bdb_attribute: tr dn: \"%s\"\n",
|
||||
target ? target->e_ndn : "" ));
|
||||
"bdb_attribute: tr dn: \"%s\"\n",
|
||||
target ? target->e_ndn : "" ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ARGS,
|
||||
"=> bdb_attribute: gr dn: \"%s\"\n",
|
||||
@ -63,8 +63,8 @@ bdb_attribute(
|
||||
e = target;
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
|
||||
"bdb_attribute: target is LOCKED (%s)\n",
|
||||
e_ndn ));
|
||||
"bdb_attribute: target is LOCKED (%s)\n",
|
||||
e_ndn ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ARGS,
|
||||
"=> bdb_attribute: target is entry: \"%s\"\n",
|
||||
@ -85,8 +85,8 @@ bdb_attribute(
|
||||
if (e == NULL) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
|
||||
"bdb_attribute: cannot find entry (%s)\n",
|
||||
e_ndn ));
|
||||
"bdb_attribute: cannot find entry (%s)\n",
|
||||
e_ndn ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ACL,
|
||||
"=> bdb_attribute: cannot find entry: \"%s\"\n",
|
||||
@ -97,21 +97,19 @@ bdb_attribute(
|
||||
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
|
||||
"bdb_attribute: found entry (%s)\n", e_ndn ));
|
||||
"bdb_attribute: found entry (%s)\n", e_ndn ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ACL,
|
||||
"=> bdb_attribute: found entry: \"%s\"\n",
|
||||
e_ndn, 0, 0 );
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* find attribute values */
|
||||
|
||||
if( is_entry_alias( e ) ) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
|
||||
"bdb_attribute: entry (%s) is an alias\n", e->e_dn ));
|
||||
"bdb_attribute: entry (%s) is an alias\n", e->e_dn ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ACL,
|
||||
"<= bdb_attribute: entry is an alias\n", 0, 0, 0 );
|
||||
@ -123,7 +121,7 @@ bdb_attribute(
|
||||
if( is_entry_referral( e ) ) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
|
||||
"bdb_attribute: entry (%s) is a referral.\n", e->e_dn ));
|
||||
"bdb_attribute: entry (%s) is a referral.\n", e->e_dn ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ACL,
|
||||
"<= bdb_attribute: entry is a referral\n", 0, 0, 0 );
|
||||
@ -143,7 +141,7 @@ bdb_attribute(
|
||||
if ((attr = attr_find(e->e_attrs, entry_at)) == NULL) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
|
||||
"bdb_attribute: failed to find %s.\n", entry_at_name ));
|
||||
"bdb_attribute: failed to find %s.\n", entry_at_name ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ACL,
|
||||
"<= bdb_attribute: failed to find %s\n",
|
||||
@ -197,8 +195,8 @@ return_results:
|
||||
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
|
||||
"bdb_attribute: rc=%d nvals=%d.\n",
|
||||
rc, j ));
|
||||
"bdb_attribute: rc=%d nvals=%d.\n",
|
||||
rc, j ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_attribute: rc=%d nvals=%d\n",
|
||||
|
@ -201,7 +201,7 @@ bdb_bind(
|
||||
|
||||
if ( (a = attr_find( e->e_attrs, krbattr )) == NULL ) {
|
||||
/*
|
||||
* no krbname values present: check against DN
|
||||
* no krbname values present: check against DN
|
||||
*/
|
||||
if ( strcasecmp( dn, krbname ) == 0 ) {
|
||||
rc = 0;
|
||||
|
@ -102,8 +102,8 @@ bdb_compare(
|
||||
rc = LDAP_COMPARE_FALSE;
|
||||
|
||||
if ( value_find_ex( ava->aa_desc,
|
||||
SLAP_MR_VALUE_IS_IN_MR_SYNTAX,
|
||||
a->a_vals, ava->aa_value ) == 0 )
|
||||
SLAP_MR_VALUE_IS_IN_MR_SYNTAX,
|
||||
a->a_vals, ava->aa_value ) == 0 )
|
||||
{
|
||||
rc = LDAP_COMPARE_TRUE;
|
||||
break;
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
int
|
||||
bdb_db_cache(
|
||||
Backend *be,
|
||||
const char *name,
|
||||
Backend *be,
|
||||
const char *name,
|
||||
DB **dbout )
|
||||
{
|
||||
int i;
|
||||
|
@ -48,18 +48,18 @@ retry: /* transaction retry */
|
||||
}
|
||||
}
|
||||
|
||||
if (bdb->bi_txn) {
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_delete: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
if( bdb->bi_txn ) {
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_delete: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
}
|
||||
|
||||
opinfo.boi_bdb = be;
|
||||
@ -283,8 +283,9 @@ retry: /* transaction retry */
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
if (bdb->bi_txn)
|
||||
if( bdb->bi_txn ) {
|
||||
rc = txn_commit( ltid, 0 );
|
||||
}
|
||||
ltid = NULL;
|
||||
op->o_private = NULL;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* error.c - BDB errcall routine */
|
||||
/* error.c - BDB errcall routine */
|
||||
/* $OpenLDAP$ */
|
||||
/*
|
||||
* Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
|
||||
|
@ -33,10 +33,10 @@ bdb_group(
|
||||
AttributeDescription *group_at
|
||||
)
|
||||
{
|
||||
struct bdbinfo *li = (struct bdbinfo *) be->be_private;
|
||||
Entry *e;
|
||||
int rc = 1;
|
||||
Attribute *attr;
|
||||
struct bdbinfo *li = (struct bdbinfo *) be->be_private;
|
||||
Entry *e;
|
||||
int rc = 1;
|
||||
Attribute *attr;
|
||||
struct berval bv;
|
||||
|
||||
AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
|
||||
@ -51,8 +51,8 @@ bdb_group(
|
||||
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
|
||||
"bdb_group: check (%s) member of (%s), oc %s\n",
|
||||
op_ndn, gr_ndn, group_oc_name ));
|
||||
"bdb_group: check (%s) member of (%s), oc %s\n",
|
||||
op_ndn, gr_ndn, group_oc_name ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ARGS,
|
||||
"=> bdb_group: gr dn: \"%s\"\n",
|
||||
@ -75,7 +75,7 @@ bdb_group(
|
||||
e = target;
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
|
||||
"bdb_group: target is group (%s)\n", gr_ndn ));
|
||||
"bdb_group: target is group (%s)\n", gr_ndn ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ARGS,
|
||||
"=> bdb_group: target is group: \"%s\"\n",
|
||||
@ -90,8 +90,8 @@ bdb_group(
|
||||
if (e == NULL) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
|
||||
"bdb_group: cannot find group (%s)\n",
|
||||
gr_ndn ));
|
||||
"bdb_group: cannot find group (%s)\n",
|
||||
gr_ndn ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ACL,
|
||||
"=> bdb_group: cannot find group: \"%s\"\n",
|
||||
@ -101,26 +101,24 @@ bdb_group(
|
||||
}
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
|
||||
"bdb_group: found group (%s)\n", gr_ndn ));
|
||||
"bdb_group: found group (%s)\n", gr_ndn ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ACL,
|
||||
"=> bdb_group: found group: \"%s\"\n",
|
||||
gr_ndn, 0, 0 );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* find it's objectClass and member attribute values
|
||||
* make sure this is a group entry
|
||||
* finally test if we can find op_dn in the member attribute value list
|
||||
*/
|
||||
|
||||
rc = 1;
|
||||
|
||||
|
||||
|
||||
if( is_entry_alias( e ) ) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
|
||||
"bdb_group: group (%s) is an alias\n", gr_ndn ));
|
||||
"bdb_group: group (%s) is an alias\n", gr_ndn ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ACL,
|
||||
"<= bdb_group: group is an alias\n", 0, 0, 0 );
|
||||
@ -131,7 +129,7 @@ bdb_group(
|
||||
if( is_entry_referral( e ) ) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
|
||||
"bdb_group: group (%s) is a referral.\n", gr_ndn ));
|
||||
"bdb_group: group (%s) is a referral.\n", gr_ndn ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ACL,
|
||||
"<= bdb_group: group is a referral\n", 0, 0, 0 );
|
||||
@ -142,8 +140,8 @@ bdb_group(
|
||||
if( !is_entry_objectclass( e, group_oc ) ) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
|
||||
"bdb_group: failed to find %s in objectClass.\n",
|
||||
group_oc_name ));
|
||||
"bdb_group: failed to find %s in objectClass.\n",
|
||||
group_oc_name ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ACL,
|
||||
"<= bdb_group: failed to find %s in objectClass\n",
|
||||
@ -155,7 +153,7 @@ bdb_group(
|
||||
if ((attr = attr_find(e->e_attrs, group_at)) == NULL) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
|
||||
"bdb_group: failed to find %s\n", group_at_name ));
|
||||
"bdb_group: failed to find %s\n", group_at_name ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ACL,
|
||||
"<= bdb_group: failed to find %s\n",
|
||||
@ -166,8 +164,8 @@ bdb_group(
|
||||
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
|
||||
"bdb_group: found objectClass %s and %s\n",
|
||||
group_oc_name, group_at_name ));
|
||||
"bdb_group: found objectClass %s and %s\n",
|
||||
group_oc_name, group_at_name ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ACL,
|
||||
"<= bdb_group: found objectClass %s and %s\n",
|
||||
@ -175,13 +173,13 @@ bdb_group(
|
||||
#endif
|
||||
|
||||
bv.bv_val = (char *) op_ndn;
|
||||
bv.bv_len = strlen( op_ndn );
|
||||
bv.bv_len = strlen( op_ndn );
|
||||
|
||||
if( value_find( group_at, attr->a_vals, &bv ) != LDAP_SUCCESS ) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
|
||||
"bdb_group: \"%s\" not in \"%s\": %s\n",
|
||||
op_ndn, gr_ndn, group_at_name ));
|
||||
"bdb_group: \"%s\" not in \"%s\": %s\n",
|
||||
op_ndn, gr_ndn, group_at_name ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ACL,
|
||||
"<= bdb_group: \"%s\" not in \"%s\": %s\n",
|
||||
@ -192,8 +190,8 @@ bdb_group(
|
||||
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
|
||||
"bdb_group: %s is in %s: %s\n",
|
||||
op_ndn, gr_ndn, group_at_name ));
|
||||
"bdb_group: %s is in %s: %s\n",
|
||||
op_ndn, gr_ndn, group_at_name ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ACL,
|
||||
"<= bdb_group: \"%s\" is in \"%s\": %s\n",
|
||||
@ -210,7 +208,7 @@ return_results:
|
||||
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
|
||||
"bdb_group: rc=%d\n", rc ));
|
||||
"bdb_group: rc=%d\n", rc ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_TRACE, "bdb_group: rc=%d\n", rc, 0, 0 );
|
||||
#endif
|
||||
|
@ -141,9 +141,11 @@ int bdb_entry_return(
|
||||
* an entry has been modified, in which case the attr list will
|
||||
* have been alloc'd separately.
|
||||
*/
|
||||
if ((void *)e->e_attrs < (void *)e ||
|
||||
(void *)e->e_attrs > e->e_private)
|
||||
attrs_free(e->e_attrs);
|
||||
if( (void *) e->e_attrs < (void *) e
|
||||
|| (void *) e->e_attrs > e->e_private )
|
||||
{
|
||||
attrs_free(e->e_attrs);
|
||||
}
|
||||
|
||||
ch_free(e);
|
||||
|
||||
|
@ -385,7 +385,7 @@ bdb_index_entry(
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
|
||||
"index_entry: success\n" ));
|
||||
"index_entry: success\n" ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"<= index_entry_%s( %ld, \"%s\" ) success\n",
|
||||
|
@ -121,9 +121,11 @@ bdb_db_open( BackendDB *be )
|
||||
}
|
||||
|
||||
flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE;
|
||||
if( bdb->bi_txn )
|
||||
|
||||
if( bdb->bi_txn ) {
|
||||
flags |= DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN | DB_RECOVER;
|
||||
else {
|
||||
|
||||
} else {
|
||||
flags |= DB_INIT_CDB;
|
||||
bdb->bi_txn_cp = 0;
|
||||
bdb->bi_dbenv->set_lk_detect(bdb->bi_dbenv, DB_LOCK_DEFAULT);
|
||||
@ -190,8 +192,8 @@ bdb_db_open( BackendDB *be )
|
||||
bdb->bi_dbenv_xflags, 1);
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bdb_db_open: dbenv_set_flags failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
"bdb_db_open: dbenv_set_flags failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
@ -264,14 +266,14 @@ bdb_db_close( BackendDB *be )
|
||||
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
|
||||
|
||||
/* force a checkpoint */
|
||||
if (bdb->bi_txn) {
|
||||
rc = txn_checkpoint( bdb->bi_dbenv, 0, 0, DB_FORCE );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
return rc;
|
||||
}
|
||||
if( bdb->bi_txn ) {
|
||||
rc = txn_checkpoint( bdb->bi_dbenv, 0, 0, DB_FORCE );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
while( bdb->bi_ndatabases-- ) {
|
||||
|
@ -19,10 +19,10 @@
|
||||
/* read a key */
|
||||
int
|
||||
bdb_key_read(
|
||||
Backend *be,
|
||||
Backend *be,
|
||||
DB *db,
|
||||
DB_TXN *txn,
|
||||
struct berval *k,
|
||||
struct berval *k,
|
||||
ID *ids
|
||||
)
|
||||
{
|
||||
@ -56,7 +56,7 @@ bdb_key_read(
|
||||
"bdb_key_read: %ld candidates\n", (long) BDB_IDL_N(ids) ));
|
||||
#else
|
||||
Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read %ld candidates\n",
|
||||
(long) BDB_IDL_N(ids), 0, 0 );
|
||||
(long) BDB_IDL_N(ids), 0, 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -66,12 +66,12 @@ bdb_key_read(
|
||||
/* Add or remove stuff from index files */
|
||||
int
|
||||
bdb_key_change(
|
||||
Backend *be,
|
||||
DB *db,
|
||||
Backend *be,
|
||||
DB *db,
|
||||
DB_TXN *txn,
|
||||
struct berval *k,
|
||||
ID id,
|
||||
int op
|
||||
struct berval *k,
|
||||
ID id,
|
||||
int op
|
||||
)
|
||||
{
|
||||
int rc;
|
||||
@ -90,12 +90,12 @@ bdb_key_change(
|
||||
bv2DBT(k,&key);
|
||||
|
||||
if (op == SLAP_INDEX_ADD_OP) {
|
||||
/* Add values */
|
||||
rc = bdb_idl_insert_key( be, db, txn, &key, id );
|
||||
/* Add values */
|
||||
rc = bdb_idl_insert_key( be, db, txn, &key, id );
|
||||
|
||||
} else {
|
||||
/* Delete values */
|
||||
rc = bdb_idl_delete_key( be, db, txn, &key, id );
|
||||
/* Delete values */
|
||||
rc = bdb_idl_delete_key( be, db, txn, &key, id );
|
||||
}
|
||||
|
||||
#ifdef NEW_LOGGING
|
||||
|
@ -187,18 +187,18 @@ retry: /* transaction retry */
|
||||
}
|
||||
}
|
||||
|
||||
if (bdb->bi_txn) {
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_modify: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
if( bdb->bi_txn ) {
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_modify: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
}
|
||||
|
||||
opinfo.boi_bdb = be;
|
||||
@ -302,8 +302,9 @@ retry: /* transaction retry */
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
if (bdb->bi_txn)
|
||||
if( bdb->bi_txn ) {
|
||||
rc = txn_commit( ltid, 0 );
|
||||
}
|
||||
ltid = NULL;
|
||||
op->o_private = NULL;
|
||||
|
||||
@ -325,7 +326,7 @@ return_results:
|
||||
send_ldap_result( conn, op, rc,
|
||||
NULL, text, NULL, NULL );
|
||||
|
||||
if(rc == LDAP_SUCCESS && bdb->bi_txn_cp ) {
|
||||
if( rc == LDAP_SUCCESS && bdb->bi_txn_cp ) {
|
||||
ldap_pvt_thread_yield();
|
||||
txn_checkpoint( bdb->bi_dbenv,
|
||||
bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
|
||||
|
@ -82,18 +82,18 @@ retry: /* transaction retry */
|
||||
}
|
||||
|
||||
|
||||
if (bdb->bi_txn) {
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_delete: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
if( bdb->bi_txn ) {
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_delete: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
}
|
||||
|
||||
opinfo.boi_bdb = be;
|
||||
@ -211,7 +211,7 @@ retry: /* transaction retry */
|
||||
|
||||
} else {
|
||||
/* no parent, modrdn entry directly under root */
|
||||
isroot = be_isroot( be, op->o_ndn );
|
||||
isroot = be_isroot( be, op->o_ndn );
|
||||
if ( ! isroot ) {
|
||||
if ( be_issuffix( be, "" ) || be_isupdate( be, op->o_ndn ) ) {
|
||||
|
||||
@ -327,7 +327,7 @@ retry: /* transaction retry */
|
||||
|
||||
} else {
|
||||
if ( isroot == -1 ) {
|
||||
isroot = be_isroot( be, op->o_ndn );
|
||||
isroot = be_isroot( be, op->o_ndn );
|
||||
}
|
||||
|
||||
np_dn = ch_strdup( "" );
|
||||
@ -608,8 +608,9 @@ retry: /* transaction retry */
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
if (bdb->bi_txn)
|
||||
if( bdb->bi_txn ) {
|
||||
rc = txn_commit( ltid, 0 );
|
||||
}
|
||||
ltid = NULL;
|
||||
op->o_private = NULL;
|
||||
|
||||
@ -631,7 +632,7 @@ return_results:
|
||||
send_ldap_result( conn, op, rc,
|
||||
NULL, text, NULL, NULL );
|
||||
|
||||
if(rc == LDAP_SUCCESS && bdb->bi_txn_cp ) {
|
||||
if( rc == LDAP_SUCCESS && bdb->bi_txn_cp ) {
|
||||
ldap_pvt_thread_yield();
|
||||
txn_checkpoint( bdb->bi_dbenv,
|
||||
bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
|
||||
|
@ -48,14 +48,14 @@ retry: if( tid != NULL ) {
|
||||
}
|
||||
}
|
||||
|
||||
if (bdb->bi_txn) {
|
||||
rc = txn_begin( bdb->bi_dbenv, tid, <id, 0 );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_next_id: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
return rc;
|
||||
}
|
||||
if( bdb->bi_txn ) {
|
||||
rc = txn_begin( bdb->bi_dbenv, tid, <id, 0 );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_next_id: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
/* get existing value for read/modify/write */
|
||||
@ -107,8 +107,7 @@ retry: if( tid != NULL ) {
|
||||
|
||||
bdb->bi_lastid = id;
|
||||
|
||||
if (bdb->bi_txn)
|
||||
{
|
||||
if (bdb->bi_txn) {
|
||||
rc = txn_commit( ltid, 0 );
|
||||
ltid = NULL;
|
||||
}
|
||||
|
@ -97,18 +97,18 @@ retry: /* transaction retry */
|
||||
}
|
||||
}
|
||||
|
||||
if (bdb->bi_txn) {
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
|
||||
*text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_exop_passwd: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
*text = "internal error";
|
||||
goto done;
|
||||
}
|
||||
if( bdb->bi_txn ) {
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
|
||||
*text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_exop_passwd: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
*text = "internal error";
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
opinfo.boi_bdb = be;
|
||||
@ -198,7 +198,8 @@ retry: /* transaction retry */
|
||||
*text = "entry update failed";
|
||||
rc = LDAP_OTHER;
|
||||
}
|
||||
if (bdb->bi_txn && rc == 0) {
|
||||
|
||||
if( bdb->bi_txn && rc == 0 ) {
|
||||
rc = txn_commit( ltid, 0 );
|
||||
ltid = NULL;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ bdb_search(
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (!manageDSAit && e != &slap_entry_root && is_entry_referral( e ) ) {
|
||||
if (!manageDSAit && e != &slap_entry_root && is_entry_referral( e ) ) {
|
||||
/* entry is a referral, don't allow add */
|
||||
char *matched_dn = ch_strdup( e->e_dn );
|
||||
struct berval **erefs = get_entry_referrals( be,
|
||||
@ -170,7 +170,7 @@ bdb_search(
|
||||
/* if no time limit requested, use soft limit (unless root!) */
|
||||
if ( isroot ) {
|
||||
if ( tlimit == 0 ) {
|
||||
tlimit = -1; /* allow root to set no limit */
|
||||
tlimit = -1; /* allow root to set no limit */
|
||||
}
|
||||
|
||||
if ( slimit == 0 ) {
|
||||
@ -533,28 +533,26 @@ static int search_candidates(
|
||||
* it just uses objectClass=*, these clauses are redundant.
|
||||
*/
|
||||
if (oc_filter(filter)) {
|
||||
if( !manageDSAit ) {
|
||||
/* match referrals */
|
||||
static struct berval bv_ref = { sizeof("REFERRAL")-1, "REFERRAL" };
|
||||
rf.f_choice = LDAP_FILTER_EQUALITY;
|
||||
rf.f_ava = &aa_ref;
|
||||
rf.f_av_desc = slap_schema.si_ad_objectClass;
|
||||
rf.f_av_value = &bv_ref;
|
||||
rf.f_next = xf.f_or;
|
||||
xf.f_or = &rf;
|
||||
}
|
||||
if( !manageDSAit ) { /* match referrals */
|
||||
static struct berval bv_ref = { sizeof("REFERRAL")-1, "REFERRAL" };
|
||||
rf.f_choice = LDAP_FILTER_EQUALITY;
|
||||
rf.f_ava = &aa_ref;
|
||||
rf.f_av_desc = slap_schema.si_ad_objectClass;
|
||||
rf.f_av_value = &bv_ref;
|
||||
rf.f_next = xf.f_or;
|
||||
xf.f_or = &rf;
|
||||
}
|
||||
|
||||
#ifdef BDB_ALIASES
|
||||
if( deref & LDAP_DEREF_SEARCHING ) {
|
||||
/* match aliases */
|
||||
static struct berval bv_alias = { sizeof("ALIAS")-1, "ALIAS" };
|
||||
af.f_choice = LDAP_FILTER_EQUALITY;
|
||||
af.f_ava = &aa_alias;
|
||||
af.f_av_desc = slap_schema.si_ad_objectClass;
|
||||
af.f_av_value = &bv_alias;
|
||||
af.f_next = xf.f_or;
|
||||
xf.f_or = ⁡
|
||||
}
|
||||
if( deref & LDAP_DEREF_SEARCHING ) { /* match aliases */
|
||||
static struct berval bv_alias = { sizeof("ALIAS")-1, "ALIAS" };
|
||||
af.f_choice = LDAP_FILTER_EQUALITY;
|
||||
af.f_ava = &aa_alias;
|
||||
af.f_av_desc = slap_schema.si_ad_objectClass;
|
||||
af.f_av_value = &bv_alias;
|
||||
af.f_next = xf.f_or;
|
||||
xf.f_or = ⁡
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -119,14 +119,14 @@ ID bdb_tool_entry_put(
|
||||
Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_put( %ld, \"%s\" )\n",
|
||||
(long) e->e_id, e->e_dn, 0 );
|
||||
|
||||
if (bdb->bi_txn) {
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, &tid, 0 );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_put: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
return NOID;
|
||||
}
|
||||
if( bdb->bi_txn ) {
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, &tid, 0 );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_put: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
return NOID;
|
||||
}
|
||||
}
|
||||
|
||||
rc = bdb_next_id( be, tid, &e->e_id );
|
||||
@ -165,22 +165,22 @@ ID bdb_tool_entry_put(
|
||||
|
||||
done:
|
||||
if( bdb->bi_txn ) {
|
||||
if( rc == 0 ) {
|
||||
rc = txn_commit( tid, 0 );
|
||||
if( rc != 0 ) {
|
||||
if( rc == 0 ) {
|
||||
rc = txn_commit( tid, 0 );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_put: txn_commit failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
e->e_id = NOID;
|
||||
}
|
||||
|
||||
} else {
|
||||
txn_abort( tid );
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_put: txn_commit failed: %s (%d)\n",
|
||||
"=> bdb_tool_entry_put: txn_aborted! %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
e->e_id = NOID;
|
||||
}
|
||||
|
||||
} else {
|
||||
txn_abort( tid );
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_put: txn_aborted! %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
e->e_id = NOID;
|
||||
}
|
||||
}
|
||||
|
||||
return e->e_id;
|
||||
@ -208,13 +208,13 @@ int bdb_tool_entry_reindex(
|
||||
}
|
||||
|
||||
if( bi->bi_txn ) {
|
||||
rc = txn_begin( bi->bi_dbenv, NULL, &tid, 0 );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_reindex: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
goto done;
|
||||
}
|
||||
rc = txn_begin( bi->bi_dbenv, NULL, &tid, 0 );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_reindex: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -229,23 +229,23 @@ int bdb_tool_entry_reindex(
|
||||
|
||||
rc = bdb_index_entry_add( be, tid, e, e->e_attrs );
|
||||
|
||||
if (bi->bi_txn) {
|
||||
if( rc == 0 ) {
|
||||
rc = txn_commit( tid, 0 );
|
||||
if( rc != 0 ) {
|
||||
if( bi->bi_txn ) {
|
||||
if( rc == 0 ) {
|
||||
rc = txn_commit( tid, 0 );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_reindex: txn_commit failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
e->e_id = NOID;
|
||||
}
|
||||
|
||||
} else {
|
||||
txn_abort( tid );
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_reindex: txn_commit failed: %s (%d)\n",
|
||||
"=> bdb_tool_entry_reindex: txn_aborted! %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
e->e_id = NOID;
|
||||
}
|
||||
|
||||
} else {
|
||||
txn_abort( tid );
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_reindex: txn_aborted! %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
e->e_id = NOID;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
|
Loading…
Reference in New Issue
Block a user