From: Howard Chu Date: Wed, 3 Apr 2013 22:04:01 +0000 (-0700) Subject: attrdb fixes X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8cc61d8dbd02232b7eace3b8aeac2deb88ae564b;p=openldap attrdb fixes --- diff --git a/servers/slapd/back-mdb/attr.c b/servers/slapd/back-mdb/attr.c index 52d3062a68..26f84b2850 100644 --- a/servers/slapd/back-mdb/attr.c +++ b/servers/slapd/back-mdb/attr.c @@ -94,6 +94,7 @@ mdb_attr_dbs_open( { struct mdb_info *mdb = (struct mdb_info *) be->be_private; MDB_txn *txn; + MDB_dbi *dbis = NULL; int i, flags; int rc; @@ -109,6 +110,7 @@ mdb_attr_dbs_open( cr->msg, 0, 0 ); return rc; } + dbis = ch_calloc( 1, mdb->mi_nattrs * sizeof(MDB_dbi) ); } else { rc = 0; } @@ -133,6 +135,9 @@ mdb_attr_dbs_open( cr->msg, 0, 0 ); break; } + /* Remember newly opened DBI handles */ + if ( dbis ) + dbis[i] = mdb->mi_attrs[i]->ai_dbi; } /* Only commit if this is our txn */ @@ -150,6 +155,17 @@ mdb_attr_dbs_open( } else { mdb_txn_abort( txn ); } + /* Something failed, forget anything we just opened */ + if ( rc ) { + for ( i=0; imi_nattrs; i++ ) { + if ( dbis[i] ) { + mdb->mi_attrs[i]->ai_dbi = 0; + mdb->mi_attrs[i]->ai_indexmask |= MDB_INDEX_DELETING; + } + } + mdb_attr_flush( mdb ); + } + ch_free( dbis ); } return rc; diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 4fb764b3e0..38d4bbea42 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -5949,8 +5949,11 @@ out: ca->reply = msg; } - if ( ca->cleanup ) - ca->cleanup( ca ); + if ( ca->cleanup ) { + i = ca->cleanup( ca ); + if (rc == LDAP_SUCCESS) + rc = i; + } out_noop: if ( rc == LDAP_SUCCESS ) { attrs_free( save_attrs );