From 6fd41cd254dd6f52ad39d97c61e0898818019792 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 18 Apr 2003 09:43:22 +0000 Subject: [PATCH] Add shm_key config keyword to use shared memory for BDB environment Unmeasurable performance difference on my tests, but who knows... --- servers/slapd/back-bdb/back-bdb.h | 1 + servers/slapd/back-bdb/config.c | 12 +++++++++++- servers/slapd/back-bdb/init.c | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index 30640a0e45..feccc5bf4e 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -157,6 +157,7 @@ struct bdb_info { u_int32_t bi_txn_cp_kbyte; int bi_lock_detect; + long bi_shm_key; ID bi_lastid; ldap_pvt_thread_mutex_t bi_lastid_mutex; diff --git a/servers/slapd/back-bdb/config.c b/servers/slapd/back-bdb/config.c index 12bf4d7324..4ebc17c649 100644 --- a/servers/slapd/back-bdb/config.c +++ b/servers/slapd/back-bdb/config.c @@ -50,7 +50,7 @@ bdb_db_config( } else if ( strcasecmp( argv[0], "dirtyread" ) == 0 ) { bdb->bi_db_opflags |= DB_DIRTY_READ; #endif - /* transaction checkpoint configuration */ + /* transaction logging configuration */ } else if ( strcasecmp( argv[0], "dbnosync" ) == 0 ) { bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC; @@ -125,6 +125,16 @@ bdb_db_config( if( rc != LDAP_SUCCESS ) return 1; + /* unique key for shared memory regions */ + } else if ( strcasecmp( argv[0], "shm_key" ) == 0 ) { + if ( argc < 2 ) { + fprintf( stderr, + "%s: line %d: missing key in \"shm_key \" line\n", + fname, lineno ); + return( 1 ); + } + bdb->bi_shm_key = atoi( argv[1] ); + /* size of the cache in entries */ } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) { if ( argc < 2 ) { diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 5e6c1d3f1f..b1314af509 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -194,6 +194,12 @@ bdb_db_open( BackendDB *be ) if( !(slapMode & SLAP_TOOL_MODE) ) flags |= DB_RECOVER; #endif + /* If a key was set, use shared memory for the BDB environment */ + if ( bdb->bi_shm_key ) { + bdb->bi_dbenv->set_shm_key( bdb->bi_dbenv, bdb->bi_shm_key ); + flags |= DB_SYSTEM_MEM; + } + bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val ); bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall ); bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect ); -- 2.39.5