struct berval bdb_uuid = { 0, NULL };
+typedef void * db_malloc(size_t);
+typedef void * db_realloc(void *, size_t);
+
static int
bdb_open( BackendInfo *bi )
{
bdb->bi_cache.c_maxsize = DEFAULT_CACHE_SIZE;
-#ifndef NO_THREADS
-#if 0
- bdb->bi_lock_detect = DB_LOCK_NORUN;
-#else
bdb->bi_lock_detect = DB_LOCK_DEFAULT;
-#endif
+
+#ifdef LDAP_CLIENT_UPDATE
+ LDAP_LIST_INIT (&bdb->psearch_list);
#endif
ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex );
return 0;
}
-#if 0 /* ifndef NO_THREADS */
-static void *lock_detect_task( void *arg )
-{
- struct bdb_info *bdb = (struct bdb_info *) arg;
-
- while( bdb->bi_dbenv != NULL ) {
- int rc;
- int aborted;
- sleep( bdb->bi_lock_detect_seconds );
-
- rc = LOCK_DETECT( bdb->bi_dbenv, 0,
- bdb->bi_lock_detect, &aborted );
-
- if( rc != 0 ) {
- break;
- }
-
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_BDB, ERR, "bdb_db_init: aborted %d locks\n",
- aborted, 0, 0 );
-#else
- Debug( LDAP_DEBUG_ANY,
- "bdb_lock_detect: aborted %d locks\n",
- aborted, 0, 0 );
-#endif
- }
-
- return NULL;
-}
-#endif
-
int
bdb_bt_compare(
DB *db,
int rc, i;
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
u_int32_t flags;
+#ifdef HAVE_EBCDIC
+ char path[MAXPATHLEN];
+#endif
#ifdef NEW_LOGGING
LDAP_LOG( BACK_BDB, ARGS,
}
flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE
- | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN | DB_RECOVER;
+ | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN;
+
+#if 0
+ /* Never do automatic recovery, must perform it manually.
+ * Otherwise restarting with gentlehup will corrupt the
+ * database.
+ */
+ if( !(slapMode & SLAP_TOOL_MODE) ) flags |= DB_RECOVER;
+#endif
bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val );
bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
-#ifndef NO_THREADS
bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect );
-#endif
#ifdef BDB_SUBDIRS
{
bdb->bi_dbenv_home, 0, 0);
#endif
+#ifdef HAVE_EBCDIC
+ strcpy( path, bdb->bi_dbenv_home );
+ __atoe( path );
+ rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
+ path,
+ flags,
+ bdb->bi_dbenv_mode );
+#else
rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
bdb->bi_dbenv_home,
flags,
bdb->bi_dbenv_mode );
+#endif
if( rc != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( BACK_BDB, ERR,
#ifdef BDB_HIER
rc = db->bdi_db->set_bt_compare( db->bdi_db,
bdb_bt_compare );
-#elif defined(BDB_IDL_MULTI)
+#else
rc = db->bdi_db->set_flags( db->bdi_db,
DB_DUP | DB_DUPSORT );
rc = db->bdi_db->set_dup_compare( db->bdi_db,
BDB_PAGESIZE );
}
- rc = db->bdi_db->open( db->bdi_db,
+#ifdef HAVE_EBCDIC
+ strcpy( path, bdbi_databases[i].file );
+ __atoe( path );
+ rc = DB_OPEN( db->bdi_db,
+ path,
+ /* bdbi_databases[i].name, */ NULL,
+ bdbi_databases[i].type,
+ bdbi_databases[i].flags | flags,
+ bdb->bi_dbenv_mode );
+#else
+ rc = DB_OPEN( db->bdi_db,
bdbi_databases[i].file,
/* bdbi_databases[i].name, */ NULL,
bdbi_databases[i].type,
bdbi_databases[i].flags | flags,
bdb->bi_dbenv_mode );
+#endif
if( rc != 0 ) {
#ifdef NEW_LOGGING
#ifdef BDB_HIER
rc = bdb_build_tree( be );
#endif
-
-#if 0 /* ifndef NO_THREADS */
- if( bdb->bi_lock_detect != DB_LOCK_NORUN ) {
- /* listener as a separate THREAD */
- rc = ldap_pvt_thread_create( &bdb->bi_lock_detect_tid,
- 1, lock_detect_task, bdb );
- }
-#endif
return 0;
}
}
}
+ if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home );
+
#ifdef BDB_HIER
ldap_pvt_thread_rdwr_destroy( &bdb->bi_tree_rdwr );
#endif
ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
+ ch_free( bdb );
+ be->be_private = NULL;
+
return 0;
}
#endif
#ifdef LDAP_CONTROL_VALUESRETURNFILTER
LDAP_CONTROL_VALUESRETURNFILTER,
+#endif
+#ifdef LDAP_CLIENT_UPDATE
+ LDAP_CONTROL_CLIENT_UPDATE,
#endif
NULL
};
{ /* version check */
int major, minor, patch;
char *version = db_version( &major, &minor, &patch );
+#ifdef HAVE_EBCDIC
+ char v2[1024];
+
+ /* All our stdio does an ASCII to EBCDIC conversion on
+ * the output. Strings from the BDB library are already
+ * in EBCDIC; we have to go back and forth...
+ */
+ strcpy( v2, version );
+ __etoa( v2 );
+ version = v2;
+#endif
if( major != DB_VERSION_MAJOR ||
minor != DB_VERSION_MINOR ||
#endif
}
-#if 0
- db_env_set_func_malloc( ch_malloc );
- db_env_set_func_realloc( ch_realloc );
- db_env_set_func_free( ch_free );
-#endif
-
+ db_env_set_func_free( ber_memfree );
+ db_env_set_func_malloc( (db_malloc *)ber_memalloc );
+ db_env_set_func_realloc( (db_realloc *)ber_memrealloc );
+#ifndef NO_THREAD
+ /* This is a no-op on a NO_THREAD build. Leave the default
+ * alone so that BDB will sleep on interprocess conflicts.
+ */
db_env_set_func_yield( ldap_pvt_thread_yield );
+#endif
{
- static char uuidbuf[40];
+ static char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
bdb_uuid.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ));
bdb_uuid.bv_val = uuidbuf;
bi->bi_chk_referrals = bdb_referrals;
bi->bi_operational = bdb_operational;
+#ifdef SLAP_X_FILTER_HASSUBORDINATES
+ bi->bi_has_subordinates = bdb_hasSubordinates;
+#endif /* SLAP_X_FILTER_HASSUBORDINATES */
bi->bi_entry_release_rw = bdb_entry_release;
/*