Fix basic operations

This commit is contained in:
Kurt Zeilenga 2001-07-31 04:24:29 +00:00
parent ca7ba1a3fd
commit 0bcc892fdf
4 changed files with 69 additions and 3 deletions

View File

@ -12,11 +12,11 @@
#include "slap.h"
#define BDB_IDL_DB_SIZE (1<<16) /* 64K IDL on disk */
#define BDB_IDL_DB_SIZE (1<<8) /* 64K IDL on disk */
#define BDB_IDL_DB_MAX (BDB_IDL_DB_SIZE-32)
/* #define BDB_IDL_DB_ALLOC (BDB_IDL_DB_SIZE * sizeof(ID)) */
#define BDB_IDL_SIZE (1<<17) /* 128K IDL in memory */
#define BDB_IDL_SIZE (1<<10) /* 128K IDL in memory */
#define BDB_IDL_MAX (BDB_IDL_DB_SIZE-32)
/* #define BDB_IDL_DB_ALLOC (BDB_IDL_DB_SIZE * sizeof(ID)) */

View File

@ -209,6 +209,16 @@ bdb_db_open( BackendDB *be )
bdb->bi_databases[i] = db;
}
/* get nextid */
rc = bdb_last_id( be, NULL );
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
"bdb_db_open: last_id(%s) failed: %s (%d)\n",
bdb->bi_dbenv_home, db_strerror(rc), rc );
return rc;
}
/* <insert> open (and create) index databases */

View File

@ -121,3 +121,58 @@ done: (void) txn_abort( ltid );
return rc;
}
int bdb_last_id( BackendDB *be, DB_TXN *tid )
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
int rc;
ID kid = NOID;
ID id;
DBT key, data;
DBTzero( &key );
key.data = (char *) &kid;
key.size = sizeof( kid );
DBTzero( &data );
data.data = (char *) &id;
data.ulen = sizeof( id );
data.flags = DB_DBT_USERMEM;
retry:
/* get existing value for read/modify/write */
rc = bdb->bi_nextid->bdi_db->get( bdb->bi_nextid->bdi_db,
tid, &key, &data, 0 );
switch(rc) {
case DB_LOCK_DEADLOCK:
case DB_LOCK_NOTGRANTED:
goto retry;
case DB_NOTFOUND:
id = 0;
rc = 0;
break;
case 0:
if ( data.size != sizeof( id ) ) {
Debug( LDAP_DEBUG_ANY,
"=> bdb_last_id: get size mismatch: expected %ld, got %ld\n",
(long) sizeof( id ), (long) data.size, 0 );
rc = -1;
goto done;
}
break;
default:
Debug( LDAP_DEBUG_ANY,
"=> bdb_next_id: get failed: %s (%d)\n",
db_strerror(rc), rc, 0 );
goto done;
}
bdb->bi_lastid = id;
done:
return rc;
}

View File

@ -181,6 +181,7 @@ bdb_key_read(
* nextid.c
*/
int bdb_next_id( BackendDB *be, DB_TXN *tid, ID *id );
int bdb_last_id( BackendDB *be, DB_TXN *tid );
/*
* modify.c