X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-mdb%2Fid2entry.c;h=2fe8d1495f8e83110809ae7300993a1de09234cb;hb=1c967b9d12f0b5e677c124dcb2475ead5978c673;hp=22456b96a4d29b7f58cd2fc8d504b93816008090;hpb=da7b9e2ea5c40fe60bb4d9151c9e370a1bdaa856;p=openldap diff --git a/servers/slapd/back-mdb/id2entry.c b/servers/slapd/back-mdb/id2entry.c index 22456b96a4..2fe8d1495f 100644 --- a/servers/slapd/back-mdb/id2entry.c +++ b/servers/slapd/back-mdb/id2entry.c @@ -165,18 +165,21 @@ int mdb_entry_release( mdb_entry_return ( e ); if ( slapMode == SLAP_SERVER_MODE ) { - rc = mdb_opinfo_get( op, mdb, 1, &moi ); - if ( rc ) - return rc; - - moi->moi_ref--; - if ( moi->moi_ref < 1 ) { - if ( moi->moi_flag & MOI_READER ) { - mdb_txn_reset( moi->moi_txn ); - } - LDAP_SLIST_REMOVE( &op->o_extra, &moi->moi_oe, OpExtra, oe_next ); - if ( moi->moi_flag & MOI_FREEIT ) { - op->o_tmpfree( moi, op->o_tmpmemctx ); + OpExtra *oex; + LDAP_SLIST_FOREACH( oex, &op->o_extra, oe_next ) { + if ( oex->oe_key == mdb ) { + moi = (mdb_op_info *)oex; + /* If it was setup by entry_get we should probably free it */ + if ( moi->moi_flag & MOI_FREEIT ) { + moi->moi_ref--; + if ( moi->moi_ref < 1 ) { + mdb_txn_reset( moi->moi_txn ); + moi->moi_ref = 0; + LDAP_SLIST_REMOVE( &op->o_extra, &moi->moi_oe, OpExtra, oe_next ); + op->o_tmpfree( moi, op->o_tmpmemctx ); + } + } + break; } } } @@ -382,11 +385,10 @@ mdb_opinfo_get( Operation *op, struct mdb_info *mdb, int rdonly, mdb_op_info **m moi->moi_txn = data; } moi->moi_flag |= MOI_READER; - } else { - if ( moi->moi_ref < 1 ) { - moi->moi_ref = 0; - mdb_txn_renew( moi->moi_txn ); - } + } + if ( moi->moi_ref < 1 ) { + moi->moi_ref = 0; + mdb_txn_renew( moi->moi_txn ); } moi->moi_ref++;