2000-09-22 14:46:32 +08:00
|
|
|
/* id2entry.c - routines to deal with the id2entry database */
|
|
|
|
/* $OpenLDAP$ */
|
|
|
|
/*
|
2003-01-04 04:20:47 +08:00
|
|
|
* Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
|
2000-09-22 14:46:32 +08:00
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ac/string.h>
|
|
|
|
|
|
|
|
#include "back-bdb.h"
|
|
|
|
|
2001-12-06 11:26:37 +08:00
|
|
|
int bdb_id2entry_put(
|
2000-09-26 07:41:16 +08:00
|
|
|
BackendDB *be,
|
2000-09-22 14:46:32 +08:00
|
|
|
DB_TXN *tid,
|
2001-12-06 11:26:37 +08:00
|
|
|
Entry *e,
|
|
|
|
int flag )
|
2000-09-22 14:46:32 +08:00
|
|
|
{
|
|
|
|
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
|
2000-09-25 06:48:13 +08:00
|
|
|
DB *db = bdb->bi_id2entry->bdi_db;
|
2000-09-22 14:46:32 +08:00
|
|
|
DBT key, data;
|
2001-12-03 22:00:19 +08:00
|
|
|
struct berval bv;
|
2000-09-22 14:46:32 +08:00
|
|
|
int rc;
|
2001-12-07 20:38:25 +08:00
|
|
|
#ifdef BDB_HIER
|
2003-03-23 23:27:43 +08:00
|
|
|
struct berval odn, ondn;
|
2000-09-22 14:46:32 +08:00
|
|
|
|
2001-12-07 20:38:25 +08:00
|
|
|
/* We only store rdns, and they go in the id2parent database. */
|
|
|
|
|
2003-03-23 23:27:43 +08:00
|
|
|
odn = e->e_name; ondn = e->e_nname;
|
2001-12-07 20:38:25 +08:00
|
|
|
|
2003-03-23 23:27:43 +08:00
|
|
|
e->e_name = slap_empty_bv;
|
|
|
|
e->e_nname = slap_empty_bv;
|
2001-12-07 20:38:25 +08:00
|
|
|
#endif
|
2000-09-22 14:46:32 +08:00
|
|
|
DBTzero( &key );
|
|
|
|
key.data = (char *) &e->e_id;
|
|
|
|
key.size = sizeof(ID);
|
|
|
|
|
|
|
|
rc = entry_encode( e, &bv );
|
2001-12-07 20:38:25 +08:00
|
|
|
#ifdef BDB_HIER
|
2003-03-23 23:27:43 +08:00
|
|
|
e->e_name = odn; e->e_nname = ondn;
|
2001-12-07 20:38:25 +08:00
|
|
|
#endif
|
2000-09-22 14:46:32 +08:00
|
|
|
if( rc != LDAP_SUCCESS ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBTzero( &data );
|
2001-12-03 22:00:19 +08:00
|
|
|
bv2DBT( &bv, &data );
|
2000-09-22 14:46:32 +08:00
|
|
|
|
2001-12-06 11:26:37 +08:00
|
|
|
rc = db->put( db, tid, &key, &data, flag );
|
2000-09-22 14:46:32 +08:00
|
|
|
|
2001-12-03 22:00:19 +08:00
|
|
|
free( bv.bv_val );
|
2000-09-28 06:28:59 +08:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2002-01-25 15:19:01 +08:00
|
|
|
/*
|
|
|
|
* This routine adds (or updates) an entry on disk.
|
|
|
|
* The cache should be already be updated.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2001-12-06 11:26:37 +08:00
|
|
|
int bdb_id2entry_add(
|
2000-09-28 06:28:59 +08:00
|
|
|
BackendDB *be,
|
|
|
|
DB_TXN *tid,
|
|
|
|
Entry *e )
|
|
|
|
{
|
2001-12-07 20:38:25 +08:00
|
|
|
return bdb_id2entry_put(be, tid, e, DB_NOOVERWRITE);
|
2001-12-06 11:26:37 +08:00
|
|
|
}
|
2000-09-28 06:28:59 +08:00
|
|
|
|
2001-12-06 11:26:37 +08:00
|
|
|
int bdb_id2entry_update(
|
|
|
|
BackendDB *be,
|
|
|
|
DB_TXN *tid,
|
|
|
|
Entry *e )
|
|
|
|
{
|
2001-12-07 20:38:25 +08:00
|
|
|
return bdb_id2entry_put(be, tid, e, 0);
|
2000-09-22 14:46:32 +08:00
|
|
|
}
|
2000-09-25 06:48:13 +08:00
|
|
|
|
2002-01-25 15:19:01 +08:00
|
|
|
int bdb_id2entry_rw(
|
2000-09-26 07:41:16 +08:00
|
|
|
BackendDB *be,
|
2000-09-25 06:48:13 +08:00
|
|
|
DB_TXN *tid,
|
|
|
|
ID id,
|
2002-01-25 15:19:01 +08:00
|
|
|
Entry **e,
|
2002-06-01 04:49:19 +08:00
|
|
|
int rw,
|
|
|
|
u_int32_t locker,
|
|
|
|
DB_LOCK *lock )
|
2000-09-25 06:48:13 +08:00
|
|
|
{
|
|
|
|
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
|
|
|
|
DB *db = bdb->bi_id2entry->bdi_db;
|
|
|
|
DBT key, data;
|
|
|
|
struct berval bv;
|
2002-06-01 04:49:19 +08:00
|
|
|
int rc = 0, ret = 0;
|
2000-09-25 06:48:13 +08:00
|
|
|
|
2000-09-26 02:59:15 +08:00
|
|
|
*e = NULL;
|
|
|
|
|
2000-09-25 06:48:13 +08:00
|
|
|
DBTzero( &key );
|
|
|
|
key.data = (char *) &id;
|
|
|
|
key.size = sizeof(ID);
|
|
|
|
|
|
|
|
DBTzero( &data );
|
|
|
|
data.flags = DB_DBT_MALLOC;
|
|
|
|
|
2002-06-01 04:49:19 +08:00
|
|
|
if ((*e = bdb_cache_find_entry_id(bdb->bi_dbenv, &bdb->bi_cache, id, rw, locker, lock)) != NULL) {
|
2002-01-25 15:19:01 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-09-25 06:48:13 +08:00
|
|
|
/* fetch it */
|
2002-06-11 03:02:25 +08:00
|
|
|
rc = db->get( db, tid, &key, &data, bdb->bi_db_opflags | ( rw ? DB_RMW : 0 ));
|
2000-09-25 06:48:13 +08:00
|
|
|
|
|
|
|
if( rc != 0 ) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBT2bv( &data, &bv );
|
|
|
|
|
|
|
|
rc = entry_decode( &bv, e );
|
|
|
|
|
2000-09-27 03:26:08 +08:00
|
|
|
if( rc == 0 ) {
|
|
|
|
(*e)->e_id = id;
|
2001-10-22 22:07:42 +08:00
|
|
|
} else {
|
|
|
|
/* only free on error. On success, the entry was
|
|
|
|
* decoded in place.
|
|
|
|
*/
|
|
|
|
ch_free( data.data );
|
2000-09-27 03:26:08 +08:00
|
|
|
}
|
2002-01-25 15:19:01 +08:00
|
|
|
|
2002-06-01 04:49:19 +08:00
|
|
|
if ( rc == 0 ) {
|
2002-09-19 14:08:12 +08:00
|
|
|
#ifdef BDB_HIER
|
|
|
|
bdb_fix_dn(be, id, *e);
|
|
|
|
#endif
|
2002-06-01 04:49:19 +08:00
|
|
|
ret = bdb_cache_add_entry_rw( bdb->bi_dbenv,
|
|
|
|
&bdb->bi_cache, *e, rw, locker, lock);
|
|
|
|
while ( ret == 1 || ret == -1 ) {
|
|
|
|
Entry *ee;
|
|
|
|
int add_loop_cnt = 0;
|
|
|
|
if ( (*e)->e_private != NULL ) {
|
|
|
|
free ((*e)->e_private);
|
|
|
|
}
|
|
|
|
(*e)->e_private = NULL;
|
|
|
|
if ( (ee = bdb_cache_find_entry_id
|
|
|
|
(bdb->bi_dbenv, &bdb->bi_cache, id, rw, locker, lock) ) != NULL) {
|
|
|
|
bdb_entry_return ( *e );
|
|
|
|
*e = ee;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if ( ++add_loop_cnt == BDB_MAX_ADD_LOOP ) {
|
|
|
|
bdb_entry_return ( *e );
|
|
|
|
*e = NULL;
|
|
|
|
return LDAP_BUSY;
|
|
|
|
}
|
2002-01-25 15:19:01 +08:00
|
|
|
}
|
2002-06-01 04:49:19 +08:00
|
|
|
if ( ret != 0 ) {
|
|
|
|
if ( (*e)->e_private != NULL )
|
|
|
|
free ( (*e)->e_private );
|
|
|
|
bdb_entry_return( *e );
|
2002-04-20 05:41:32 +08:00
|
|
|
*e = NULL;
|
|
|
|
}
|
2002-06-01 04:49:19 +08:00
|
|
|
rc = ret;
|
2002-01-25 15:19:01 +08:00
|
|
|
}
|
|
|
|
|
2002-01-29 08:02:27 +08:00
|
|
|
if (rc == 0) {
|
2002-01-25 15:19:01 +08:00
|
|
|
bdb_cache_entry_commit(*e);
|
2002-01-29 08:02:27 +08:00
|
|
|
}
|
2002-01-25 15:19:01 +08:00
|
|
|
|
2000-09-25 06:48:13 +08:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int bdb_id2entry_delete(
|
2000-09-26 07:41:16 +08:00
|
|
|
BackendDB *be,
|
2000-09-25 06:48:13 +08:00
|
|
|
DB_TXN *tid,
|
2002-01-25 15:19:01 +08:00
|
|
|
Entry *e )
|
2000-09-25 06:48:13 +08:00
|
|
|
{
|
|
|
|
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
|
|
|
|
DB *db = bdb->bi_id2entry->bdi_db;
|
|
|
|
DBT key;
|
|
|
|
int rc;
|
|
|
|
|
2002-01-25 15:19:01 +08:00
|
|
|
bdb_cache_delete_entry(&bdb->bi_cache, e);
|
|
|
|
|
2000-09-25 06:48:13 +08:00
|
|
|
DBTzero( &key );
|
2002-01-25 15:19:01 +08:00
|
|
|
key.data = (char *) &e->e_id;
|
2000-09-25 06:48:13 +08:00
|
|
|
key.size = sizeof(ID);
|
|
|
|
|
2002-01-25 15:19:01 +08:00
|
|
|
/* delete from database */
|
2000-09-25 06:48:13 +08:00
|
|
|
rc = db->del( db, tid, &key, 0 );
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int bdb_entry_return(
|
|
|
|
Entry *e )
|
|
|
|
{
|
2001-12-05 08:24:13 +08:00
|
|
|
/* 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
|
2002-01-25 15:19:01 +08:00
|
|
|
* in e_bv. Since the Entry structure is allocated as a single
|
2001-12-05 08:24:13 +08:00
|
|
|
* block, e_attrs is always a fixed offset from e. The exception
|
|
|
|
* is when an entry has been modified, in which case we also need
|
|
|
|
* to free e_attrs.
|
2001-10-22 22:07:42 +08:00
|
|
|
*/
|
2002-01-25 15:19:01 +08:00
|
|
|
if( !e->e_bv.bv_val ) { /* A regular entry, from do_add */
|
|
|
|
entry_free( e );
|
|
|
|
return 0;
|
|
|
|
}
|
2001-12-05 08:24:13 +08:00
|
|
|
if( (void *) e->e_attrs != (void *) (e+1)) {
|
|
|
|
attrs_free( e->e_attrs );
|
|
|
|
}
|
2002-01-25 15:19:01 +08:00
|
|
|
|
2002-05-03 22:47:29 +08:00
|
|
|
#ifndef BDB_HIER
|
2002-01-25 15:19:01 +08:00
|
|
|
/* 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;
|
|
|
|
}
|
2002-05-03 22:47:29 +08:00
|
|
|
#else
|
2001-12-09 09:14:32 +08:00
|
|
|
/* We had to construct the dn and ndn as well, in a single block */
|
2002-01-25 15:19:01 +08:00
|
|
|
if( e->e_name.bv_val ) {
|
|
|
|
free( e->e_name.bv_val );
|
|
|
|
}
|
2001-12-09 09:14:32 +08:00
|
|
|
#endif
|
2002-01-25 15:19:01 +08:00
|
|
|
/* In tool mode the e_bv buffer is realloc'd, leave it alone */
|
|
|
|
if( !(slapMode & SLAP_TOOL_MODE) ) {
|
|
|
|
free( e->e_bv.bv_val );
|
2001-11-27 11:41:03 +08:00
|
|
|
}
|
2001-10-22 22:07:42 +08:00
|
|
|
|
2001-12-05 08:24:13 +08:00
|
|
|
free( e );
|
2001-10-22 22:07:42 +08:00
|
|
|
|
2000-09-25 06:48:13 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2001-12-07 20:38:25 +08:00
|
|
|
|
2001-11-27 17:34:53 +08:00
|
|
|
int bdb_entry_release(
|
|
|
|
Operation *o,
|
|
|
|
Entry *e,
|
|
|
|
int rw )
|
|
|
|
{
|
2003-03-30 17:03:54 +08:00
|
|
|
struct bdb_info *bdb = (struct bdb_info *) o->o_bd->be_private;
|
2003-03-26 21:33:51 +08:00
|
|
|
struct bdb_op_info *boi = NULL;
|
2002-01-25 15:19:01 +08:00
|
|
|
|
|
|
|
/* slapMode : SLAP_SERVER_MODE, SLAP_TOOL_MODE,
|
|
|
|
SLAP_TRUNCATE_MODE, SLAP_UNDEFINED_MODE */
|
|
|
|
|
|
|
|
if ( slapMode == SLAP_SERVER_MODE ) {
|
|
|
|
/* free entry and reader or writer lock */
|
2003-03-26 21:33:51 +08:00
|
|
|
if ( o ) {
|
|
|
|
boi = (struct bdb_op_info *)o->o_private;
|
|
|
|
}
|
|
|
|
/* lock is freed with txn */
|
2003-03-27 11:27:48 +08:00
|
|
|
if ( !boi || boi->boi_txn ) {
|
2003-03-26 21:33:51 +08:00
|
|
|
bdb_unlocked_cache_return_entry_rw( &bdb->bi_cache, e, rw );
|
|
|
|
} else {
|
|
|
|
bdb_cache_return_entry_rw( bdb->bi_dbenv, &bdb->bi_cache, e, rw, &boi->boi_lock );
|
|
|
|
ch_free( boi );
|
|
|
|
o->o_private = NULL;
|
|
|
|
}
|
2002-01-25 15:19:01 +08:00
|
|
|
} else {
|
|
|
|
if (e->e_private != NULL)
|
|
|
|
free (e->e_private);
|
|
|
|
e->e_private = NULL;
|
|
|
|
bdb_entry_return ( e );
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2001-11-27 17:34:53 +08:00
|
|
|
}
|
2003-03-26 19:50:03 +08:00
|
|
|
|
|
|
|
/* return LDAP_SUCCESS IFF we can retrieve the specified entry.
|
|
|
|
*/
|
|
|
|
int bdb_entry_get(
|
|
|
|
Operation *op,
|
|
|
|
struct berval *ndn,
|
|
|
|
ObjectClass *oc,
|
|
|
|
AttributeDescription *at,
|
|
|
|
int rw,
|
|
|
|
Entry **ent )
|
|
|
|
{
|
2003-03-30 17:03:54 +08:00
|
|
|
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
|
2003-03-26 19:50:03 +08:00
|
|
|
struct bdb_op_info *boi = NULL;
|
|
|
|
DB_TXN *txn = NULL;
|
|
|
|
Entry *e;
|
|
|
|
int rc;
|
|
|
|
const char *at_name = at->ad_cname.bv_val;
|
|
|
|
|
|
|
|
u_int32_t locker = 0;
|
|
|
|
DB_LOCK lock;
|
|
|
|
int free_lock_id = 0;
|
|
|
|
|
|
|
|
#ifdef NEW_LOGGING
|
|
|
|
LDAP_LOG( BACK_BDB, ARGS,
|
|
|
|
"bdb_entry_get: ndn: \"%s\"\n", ndn->bv_val, 0, 0 );
|
|
|
|
LDAP_LOG( BACK_BDB, ARGS,
|
|
|
|
"bdb_entry_get: oc: \"%s\", at: \"%s\"\n",
|
|
|
|
oc ? oc->soc_cname.bv_val : "(null)", at_name, 0);
|
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ARGS,
|
|
|
|
"=> bdb_entry_get: ndn: \"%s\"\n", ndn->bv_val, 0, 0 );
|
|
|
|
Debug( LDAP_DEBUG_ARGS,
|
|
|
|
"=> bdb_entry_get: oc: \"%s\", at: \"%s\"\n",
|
|
|
|
oc ? oc->soc_cname.bv_val : "(null)", at_name, 0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if( op ) boi = (struct bdb_op_info *) op->o_private;
|
2003-03-30 17:03:54 +08:00
|
|
|
if( boi != NULL && op->o_bd == boi->boi_bdb ) {
|
2003-03-26 19:50:03 +08:00
|
|
|
txn = boi->boi_txn;
|
|
|
|
locker = boi->boi_locker;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( txn != NULL ) {
|
|
|
|
locker = TXN_ID ( txn );
|
|
|
|
} else if ( !locker ) {
|
|
|
|
rc = LOCK_ID ( bdb->bi_dbenv, &locker );
|
|
|
|
free_lock_id = 1;
|
|
|
|
switch(rc) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return LDAP_OTHER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dn2entry_retry:
|
|
|
|
/* can we find entry */
|
2003-03-30 17:03:54 +08:00
|
|
|
rc = bdb_dn2entry_rw( op->o_bd, txn, ndn, &e, NULL, 0, rw, locker, &lock );
|
2003-03-26 19:50:03 +08:00
|
|
|
switch( rc ) {
|
|
|
|
case DB_NOTFOUND:
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case DB_LOCK_DEADLOCK:
|
|
|
|
case DB_LOCK_NOTGRANTED:
|
|
|
|
/* the txn must abort and retry */
|
|
|
|
if ( txn ) {
|
|
|
|
boi->boi_err = rc;
|
|
|
|
return LDAP_BUSY;
|
|
|
|
}
|
|
|
|
ldap_pvt_thread_yield();
|
|
|
|
goto dn2entry_retry;
|
|
|
|
default:
|
|
|
|
boi->boi_err = rc;
|
|
|
|
if ( free_lock_id ) {
|
|
|
|
LOCK_ID_FREE( bdb->bi_dbenv, locker );
|
|
|
|
}
|
|
|
|
return (rc != LDAP_BUSY) ? LDAP_OTHER : LDAP_BUSY;
|
|
|
|
}
|
|
|
|
if (e == NULL) {
|
|
|
|
#ifdef NEW_LOGGING
|
|
|
|
LDAP_LOG( BACK_BDB, INFO,
|
|
|
|
"bdb_entry_get: cannot find entry (%s)\n",
|
|
|
|
ndn->bv_val, 0, 0 );
|
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"=> bdb_entry_get: cannot find entry: \"%s\"\n",
|
|
|
|
ndn->bv_val, 0, 0 );
|
|
|
|
#endif
|
|
|
|
if ( free_lock_id ) {
|
|
|
|
LOCK_ID_FREE( bdb->bi_dbenv, locker );
|
|
|
|
}
|
|
|
|
return LDAP_NO_SUCH_OBJECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NEW_LOGGING
|
|
|
|
LDAP_LOG( BACK_BDB, DETAIL1, "bdb_entry_get: found entry (%s)\n",
|
|
|
|
ndn->bv_val, 0, 0 );
|
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"=> bdb_entry_get: found entry: \"%s\"\n",
|
|
|
|
ndn->bv_val, 0, 0 );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BDB_ALIASES
|
|
|
|
/* find attribute values */
|
|
|
|
if( is_entry_alias( e ) ) {
|
|
|
|
#ifdef NEW_LOGGING
|
|
|
|
LDAP_LOG( BACK_BDB, INFO,
|
|
|
|
"bdb_entry_get: entry (%s) is an alias\n", e->e_name.bv_val, 0, 0 );
|
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"<= bdb_entry_get: entry is an alias\n", 0, 0, 0 );
|
|
|
|
#endif
|
|
|
|
rc = LDAP_ALIAS_PROBLEM;
|
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if( is_entry_referral( e ) ) {
|
|
|
|
#ifdef NEW_LOGGING
|
|
|
|
LDAP_LOG( BACK_BDB, INFO,
|
|
|
|
"bdb_entry_get: entry (%s) is a referral.\n", e->e_name.bv_val, 0, 0);
|
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"<= bdb_entry_get: entry is a referral\n", 0, 0, 0 );
|
|
|
|
#endif
|
|
|
|
rc = LDAP_REFERRAL;
|
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( oc && !is_entry_objectclass( e, oc, 0 )) {
|
|
|
|
#ifdef NEW_LOGGING
|
|
|
|
LDAP_LOG( BACK_BDB, INFO,
|
|
|
|
"bdb_entry_get: failed to find objectClass.\n", 0, 0, 0 );
|
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_ACL,
|
|
|
|
"<= bdb_entry_get: failed to find objectClass\n",
|
|
|
|
0, 0, 0 );
|
|
|
|
#endif
|
|
|
|
rc = LDAP_NO_SUCH_ATTRIBUTE;
|
|
|
|
goto return_results;
|
|
|
|
}
|
|
|
|
|
|
|
|
return_results:
|
|
|
|
if( rc != LDAP_SUCCESS ) {
|
|
|
|
/* free entry */
|
|
|
|
bdb_cache_return_entry_rw(bdb->bi_dbenv, &bdb->bi_cache, e, rw, &lock);
|
|
|
|
} else {
|
|
|
|
*ent = e;
|
2003-03-26 21:33:51 +08:00
|
|
|
/* big drag. we need a place to store a read lock so we can
|
|
|
|
* release it later??
|
|
|
|
*/
|
|
|
|
if ( op && !boi ) {
|
|
|
|
boi = ch_calloc(1,sizeof(struct bdb_op_info));
|
|
|
|
boi->boi_lock = lock;
|
|
|
|
op->o_private = boi;
|
|
|
|
}
|
2003-03-26 19:50:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( free_lock_id ) {
|
|
|
|
LOCK_ID_FREE( bdb->bi_dbenv, locker );
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NEW_LOGGING
|
|
|
|
LDAP_LOG( BACK_BDB, ENTRY, "bdb_entry_get: rc=%d\n", rc, 0, 0 );
|
|
|
|
#else
|
|
|
|
Debug( LDAP_DEBUG_TRACE,
|
|
|
|
"bdb_entry_get: rc=%d\n",
|
|
|
|
rc, 0, 0 );
|
|
|
|
#endif
|
|
|
|
return(rc);
|
|
|
|
}
|