Commit 2eda0bd7 authored by Howard Chu's avatar Howard Chu Committed by Quanah Gibson-Mount
Browse files

ITS#9091 drop attr mappings added in an aborted txn

If a txn is aborted in id2entry_put, attribute index mappings
added during that txn must also be dropped from memory.
parent f39ad630
......@@ -628,3 +628,14 @@ int mdb_ad_get( struct mdb_info *mdb, MDB_txn *txn, AttributeDescription *ad )
return rc;
}
void mdb_ad_unwind( struct mdb_info *mdb, int prev_ads )
{
int i;
for (i=mdb->mi_numads; i>prev_ads; i--) {
mdb->mi_adxs[mdb->mi_ads[i]->ad_index] = 0;
mdb->mi_ads[i] = NULL;
}
mdb->mi_numads = i;
}
......@@ -47,7 +47,7 @@ static int mdb_id2entry_put(
struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private;
Ecount ec;
MDB_val key, data;
int rc;
int rc, prev_ads = mdb->mi_numads;
/* We only store rdns, and they go in the dn2id database. */
......@@ -55,8 +55,10 @@ static int mdb_id2entry_put(
key.mv_size = sizeof(ID);
rc = mdb_entry_partsize( mdb, txn, e, &ec );
if (rc)
return LDAP_OTHER;
if (rc) {
rc = LDAP_OTHER;
goto fail;
}
flag |= MDB_RESERVE;
......@@ -72,7 +74,7 @@ again:
if (rc == MDB_SUCCESS) {
rc = mdb_entry_encode( op, e, &data, &ec );
if( rc != LDAP_SUCCESS )
return rc;
goto fail;
}
if (rc) {
/* Was there a hole from slapadd? */
......@@ -87,6 +89,10 @@ again:
if ( rc != MDB_KEYEXIST )
rc = LDAP_OTHER;
}
fail:
if (rc) {
mdb_ad_unwind( mdb, prev_ads );
}
return rc;
}
......
......@@ -48,6 +48,7 @@ void mdb_attr_info_free( AttrInfo *ai );
int mdb_ad_read( struct mdb_info *mdb, MDB_txn *txn );
int mdb_ad_get( struct mdb_info *mdb, MDB_txn *txn, AttributeDescription *ad );
void mdb_ad_unwind( struct mdb_info *mdb, int prev_ads );
/*
* config.c
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment