int flag )
{
struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private;
- MDB_dbi dbi = mdb->mi_id2entry->mdi_dbi;
+ MDB_dbi dbi = mdb->mi_id2entry;
MDB_val key, data;
struct berval bv;
int rc;
key.mv_data = &e->e_id;
key.mv_size = sizeof(ID);
- rc = mdb_entry_encode( op, e, &bv );
+ rc = entry_encode( e, &bv );
e->e_name = odn; e->e_nname = ondn;
if( rc != LDAP_SUCCESS ) {
return -1;
Entry **e )
{
struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private;
- MDB_dbi dbi = mdb->mi_id2entry->mdi_dbi;
+ MDB_dbi dbi = mdb->mi_id2entry;
MDB_val key, data;
EntryHeader eh;
- char buf[16];
- int rc = 0, off;
+ int rc = 0;
*e = NULL;
rc = mdb_get( tid, dbi, &key, &data );
if ( rc ) return rc;
- rc = mdb_entry_decode(&eh, e);
+ eh.bv.bv_val = data.mv_data;
+ eh.bv.bv_len = data.mv_size;
+ rc = entry_header( &eh );
+ if ( rc ) return rc;
+
+ eh.bv.bv_len = eh.nvals * sizeof( struct berval );
+ eh.bv.bv_val = ch_malloc( eh.bv.bv_len );
+ rc = entry_decode(&eh, e);
if( rc == 0 ) {
(*e)->e_id = id;
+ (*e)->e_bv = eh.bv;
+ } else {
+ ch_free( eh.bv.bv_val );
}
return rc;
Entry *e )
{
struct mdb_info *mdb = (struct mdb_info *) be->be_private;
- MDB_dbi dbi = mdb->mi_id2entry->mdi_dbi;
+ MDB_dbi dbi = mdb->mi_id2entry;
MDB_val key;
int rc;
Entry *e
)
{
- /* Our entries are allocated in two blocks; the data comes from
- * the db itself and the Entry structure and associated pointers
- * are allocated in entry_decode. The db data pointer is saved
- * in e_bv.
- */
- if ( e->e_bv.bv_val ) {
- /* See if the DNs were changed by modrdn */
- if( e->e_nname.bv_val < e->e_bv.bv_val || e->e_nname.bv_val >
- e->e_bv.bv_val + e->e_bv.bv_len ) {
- ch_free(e->e_name.bv_val);
- ch_free(e->e_nname.bv_val);
- }
- e->e_name.bv_val = NULL;
- e->e_nname.bv_val = NULL;
- /* In tool mode the e_bv buffer is realloc'd, leave it alone */
- if( !(slapMode & SLAP_TOOL_MODE) ) {
- free( e->e_bv.bv_val );
- }
- BER_BVZERO( &e->e_bv );
- }
entry_free( e );
return 0;
}
Entry *e,
int rw )
{
+#if 0
struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private;
struct mdb_op_info *moi;
OpExtra *oex;
}
return 0;
+#else
+ return mdb_entry_return( e );
+#endif
}
/* return LDAP_SUCCESS IFF we can retrieve the specified entry.
Entry **ent )
{
struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private;
- struct mdb_op_info *boi = NULL;
- DB_TXN *txn = NULL;
+ struct mdb_op_info *moi = NULL;
+ MDB_txn *txn = NULL;
Entry *e = NULL;
- EntryInfo *ei;
int rc;
const char *at_name = at ? at->ad_cname.bv_val : "(null)";
- DB_LOCK lock;
-
Debug( LDAP_DEBUG_ARGS,
"=> mdb_entry_get: ndn: \"%s\"\n", ndn->bv_val, 0, 0 );
Debug( LDAP_DEBUG_ARGS,
LDAP_SLIST_FOREACH( oex, &op->o_extra, oe_next ) {
if ( oex->oe_key == mdb ) break;
}
- boi = (struct mdb_op_info *)oex;
- if ( boi )
- txn = boi->boi_txn;
+ moi = (struct mdb_op_info *)oex;
+ if ( moi )
+ txn = moi->moi_txn;
}
if ( !txn ) {
- rc = mdb_reader_get( op, mdb->bi_dbenv, &txn );
+ rc = mdb_reader_get( op, mdb->mi_dbenv, &txn );
switch(rc) {
case 0:
break;
}
}
-dn2entry_retry:
/* can we find entry */
- rc = mdb_dn2entry( op, txn, ndn, &ei, 0, &lock );
+ rc = mdb_dn2entry( op, txn, ndn, &e, 0 );
switch( rc ) {
case MDB_NOTFOUND:
case 0:
break;
default:
- if ( boi ) boi->boi_err = rc;
return (rc != LDAP_BUSY) ? LDAP_OTHER : LDAP_BUSY;
}
- if (ei) e = ei->bei_e;
if (e == NULL) {
Debug( LDAP_DEBUG_ACL,
"=> mdb_entry_get: cannot find entry: \"%s\"\n",
return_results:
if( rc != LDAP_SUCCESS ) {
/* free entry */
- mdb_cache_return_entry_rw(mdb, e, rw, &lock);
+ mdb_entry_return( e );
} else {
- if ( slapMode == SLAP_SERVER_MODE ) {
- *ent = e;
- /* big drag. we need a place to store a read lock so we can
- * release it later?? If we're in a txn, nothing is needed
- * here because the locks will go away with the txn.
- */
- if ( op ) {
- if ( !boi ) {
- boi = op->o_tmpcalloc(1,sizeof(struct mdb_op_info),op->o_tmpmemctx);
- boi->boi_oe.oe_key = mdb;
- LDAP_SLIST_INSERT_HEAD( &op->o_extra, &boi->boi_oe, oe_next );
- }
- if ( !boi->boi_txn ) {
- struct mdb_lock_info *bli;
- bli = op->o_tmpalloc( sizeof(struct mdb_lock_info),
- op->o_tmpmemctx );
- bli->bli_next = boi->boi_locks;
- bli->bli_id = e->e_id;
- bli->bli_flag = 0;
- bli->bli_lock = lock;
- boi->boi_locks = bli;
- }
- }
- } else {
- *ent = entry_dup( e );
- mdb_cache_return_entry_rw(mdb, e, rw, &lock);
- }
+ *ent = entry_dup( e );
}
Debug( LDAP_DEBUG_TRACE,