goto return_results;
}
-#ifdef BDB_INDEX
/* attribute indexes */
if ( bdb_index_entry_add( be, ltid, e, e->e_attrs ) != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "bdb_add: index_entry_add failed\n",
text = "index generation failed";
goto return_results;
}
-#endif
rc = txn_commit( ltid, 0 );
ltid = NULL;
#include "slap.h"
#include "back-bdb.h"
-#if BDB_CONFIG_INDICES
-
/* for the cache of attribute information (which are indexed, etc.) */
typedef struct bdb_attrinfo {
#ifdef SLAPD_USE_AD
avl_free( tree, ainfo_free );
}
-#endif
LDAP_BEGIN_DECL
-/* #define BDB_INDEX 1 */
-/* #define BDB_REINDEX 1 */
/* #define BDB_FILTER_INDICES 1 */
-#define BDB_CONFIG_INDICES 1
/* #define SLAPD_USE_AD 1 */
#define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX
int bi_ndatabases;
struct bdb_db_info **bi_databases;
+ ldap_pvt_thread_mutex_t bi_database_mutex;
+
+ slap_mask_t bi_defaultmask;
+ Avlnode *bi_attrs;
int bi_txn_cp;
u_int32_t bi_txn_cp_min;
ldap_pvt_thread_t bi_lock_detect_tid;
#endif
-#if BDB_CONFIG_INDICES
- slap_mask_t bi_defaultmask;
- Avlnode *bi_attrs;
-#endif
-
ID bi_lastid;
};
*dbout = NULL;
- for( i=BDB_NDB; bdb->bi_databases[i]->bdi_name; i++ ) {
+ for( i=BDB_NDB; bdb->bi_databases[i]; i++ ) {
if( !strcmp( bdb->bi_databases[i]->bdi_name, name) ) {
*dbout = bdb->bi_databases[i]->bdi_db;
return 0;
}
}
+ ldap_pvt_thread_mutex_lock( &bdb->bi_database_mutex );
+
+ /* check again! may have been added by another thread */
+ for( i=BDB_NDB; bdb->bi_databases[i]; i++ ) {
+ if( !strcmp( bdb->bi_databases[i]->bdi_name, name) ) {
+ *dbout = bdb->bi_databases[i]->bdi_db;
+ ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
+ return 0;
+ }
+ }
+
if( i >= BDB_INDICES ) {
+ ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
return -1;
}
Debug( LDAP_DEBUG_ANY,
"bdb_db_cache: db_create(%s) failed: %s (%d)\n",
bdb->bi_dbenv_home, db_strerror(rc), rc );
+ ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
return rc;
}
Debug( LDAP_DEBUG_ANY,
"bdb_db_cache: db_open(%s) failed: %s (%d)\n",
name, db_strerror(rc), rc );
+ ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
return rc;
}
+ bdb->bi_databases[i+1] = NULL;
bdb->bi_databases[i] = db;
*dbout = db->bdi_db;
+ ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
return 0;
}
#include "slap.h"
#include "back-bdb.h"
-#ifdef BDB_INDEX
-
static slap_mask_t index_mask(
Backend *be,
AttributeDescription *desc,
return LDAP_SUCCESS;
}
-
-#endif
bdb->bi_lock_detect = DB_LOCK_NORUN;
#endif
+ ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex );
+
be->be_private = bdb;
return 0;
}
bi->bi_tool_entry_next = bdb_tool_entry_next;
bi->bi_tool_entry_get = bdb_tool_entry_get;
bi->bi_tool_entry_put = bdb_tool_entry_put;
-#if BDB_REINDEX
bi->bi_tool_entry_reindex = bdb_tool_entry_reindex;
-#else
- bi->bi_tool_entry_reindex = 0;
-#endif
bi->bi_tool_sync = 0;
bi->bi_connection_init = 0;
#include "slap.h"
#include "back-bdb.h"
+#include "idl.h"
-#ifdef BDB_FILTER_INDICES
/* read a key */
int
bdb_key_read(
ID *ids
)
{
- DBT key;
+ int rc;
+ DBT key;
#ifdef NEW_LOGGING
LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 );
#endif
- DBzero( &key );
+ DBTzero( &key );
bv2DBT(k,&key);
- rc = bdb_idl_fetch_key( be, db, txn, key, ids );
+ rc = bdb_idl_fetch_key( be, db, txn, &key, ids );
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
} else {
#ifdef NEW_LOGGING
LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
- "bdb_key_read: %ld candidates\n",
- idl ? ID_BLOCK_NIDS(idl) : 0 ));
+ "bdb_key_read: %ld candidates\n", BDB_IDL_N(ids) );
#else
Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read %ld candidates\n",
- idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
+ BDB_IDL_N(ids), 0, 0 );
#endif
}
return rc;
}
-#endif
-#ifdef BDB_INDEX
/* Add or remove stuff from index files */
int
bdb_key_change(
return rc;
}
-#endif
return rc;
}
-#ifdef BDB_INDEX
/* delete indices for old attributes */
rc = bdb_index_entry_del( be, tid, e, save_attrs);
if ( rc != LDAP_SUCCESS ) {
attrs_free( e->e_attrs );
e->e_attrs = save_attrs;
- Debug( LDAP_DEBUG_ANY, "entry index delete failed: %s\n",
- *text, 0, 0 );
+ Debug( LDAP_DEBUG_ANY, "entry index delete failed!\n",
+ 0, 0, 0 );
return rc;
}
if ( rc != LDAP_SUCCESS ) {
attrs_free( e->e_attrs );
e->e_attrs = save_attrs;
- Debug( LDAP_DEBUG_ANY, "entry index add failed: %s\n",
- *text, 0, 0 );
+ Debug( LDAP_DEBUG_ANY, "entry index add failed!\n",
+ 0, 0, 0 );
return rc;
}
-#endif
attrs_free( save_attrs );
return rc;
goto done;
}
-#ifdef BDB_INDEX
rc = bdb_index_entry_add( be, tid, e, e->e_attrs );
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
db_strerror(rc), rc, 0 );
goto done;
}
-#endif
done:
if( rc == 0 ) {
return e->e_id;
}
-#if BDB_REINDEX
int bdb_tool_entry_reindex(
BackendDB *be,
ID id )
entry_free( e );
return rc;
}
-#endif