bdb->bi_dbenv_home = ch_strdup( argv[1] );
- /* mode with which to create new database files */
+ /* transaction checkpoint configuration */
+ } else if ( strcasecmp( argv[0], "dbnosync" ) == 0 ) {
+ bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC;
+
+ /* transaction checkpoint configuration */
} else if ( strcasecmp( argv[0], "checkpoint" ) == 0 ) {
if ( argc < 3 ) {
fprintf( stderr, "%s: line %d: "
bdb->bi_txn_cp_kbyte = strtol( argv[1], NULL, 0 );
bdb->bi_txn_cp_min = strtol( argv[2], NULL, 0 );
+ /* lock detect configuration */
+ } else if ( strcasecmp( argv[0], "lockdetect" ) == 0 ) {
+#ifndef NO_THREADS
+ if ( argc < 3 ) {
+ fprintf( stderr, "%s: line %d: "
+ "missing parameters in \"lockDetect <policy> <seconds>\" line\n",
+ fname, lineno );
+ return 1;
+ }
+
+ if( strcasecmp( argv[1], "default" ) == 0 ) {
+ bdb->bi_lock_detect = DB_LOCK_DEFAULT;
+
+ } else if( strcasecmp( argv[1], "oldest" ) == 0 ) {
+ bdb->bi_lock_detect = DB_LOCK_OLDEST;
+
+ } else if( strcasecmp( argv[1], "random" ) == 0 ) {
+ bdb->bi_lock_detect = DB_LOCK_RANDOM;
+
+ } else if( strcasecmp( argv[1], "youngest" ) == 0 ) {
+ bdb->bi_lock_detect = DB_LOCK_YOUNGEST;
+
+ } else {
+ fprintf( stderr, "%s: line %d: "
+ "bad policy (%s) in \"lockDetect <policy> <seconds>\" line\n",
+ fname, lineno, argv[1] );
+ return 1;
+ }
+
+ bdb->bi_lock_detect_seconds = strtol( argv[2], NULL, 0 );
+ if( bdb->bi_lock_detect_seconds < 1 ) {
+ fprintf( stderr, "%s: line %d: "
+ "bad seconds (%s) in \"lockDetect <policy> <seconds>\" line\n",
+ fname, lineno, argv[2] );
+ return 1;
+ }
+#else
+ fprintf( stderr, "%s: line %d: "
+ "NO THREADS: lockDetect line ignored\n",
+ fname, lineno );
+#endif
+
/* mode with which to create new database files */
} else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
if ( argc < 2 ) {
bdb->bi_dbenv_xflags = 0;
bdb->bi_dbenv_mode = DEFAULT_MODE;
+ bdb->bi_lock_detect = DB_LOCK_NORUN;
+
be->be_private = bdb;
return 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;
+ sleep( bdb->bi_lock_detect_seconds );
+
+ rc = lock_detect( bdb->bi_dbenv, DB_LOCK_CONFLICT, bdb->bi_lock_detect, NULL );
+ if( rc != 0 ) {
+ break;
+ }
+ }
+
+ return NULL;
+}
+#endif
+
static int
bdb_db_open( BackendDB *be )
{
return rc;
}
- flags = DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN |
- DB_CREATE | DB_RECOVER | DB_THREAD;
+ flags = DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN |
+ DB_CREATE | DB_RECOVER;
-#ifdef SLAPD_BDB_PRIVATE
- flags |= DB_PRIVATE;
-#else
- flags |= DB_INIT_MPOOL;
+#ifndef NO_THREADS
+ flags |= DB_THREAD;
#endif
bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0] );
/* <insert> open (and create) index databases */
+#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;
}