Skip to content
Snippets Groups Projects
Commit 0bcc892f authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Fix basic operations

parent ca7ba1a3
No related branches found
No related tags found
No related merge requests found
......@@ -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)) */
......@@ -54,4 +54,4 @@
LDAP_BEGIN_DECL
LDAP_END_DECL
#endif
\ No newline at end of file
#endif
......@@ -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 */
......
......@@ -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;
}
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment