From: Kurt Zeilenga Date: Mon, 18 Sep 2000 21:19:19 +0000 (+0000) Subject: Add set_*_dir calls X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1953 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=da5da64ef855779bf1f552434fa2420402523f84;p=openldap Add set_*_dir calls --- diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index b3601e89c6..286ce53ed1 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -17,11 +17,11 @@ LDAP_BEGIN_DECL #define DEFAULT_MODE 0600 -#define DEFAULT_DBENV_HOME LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb-home" -#define DEFAULT_DBENV_MODE DEFAULT_MODE +#define DEFAULT_DBENV_HOME LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb" -#define DEFAULT_DB_DIRECTORY LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb" -#define DEFAULT_DB_MODE DEFAULT_MODE +#define DEFAULT_DB_TMP_DIR DEFAULT_DBENV_HOME LDAP_DIRSEP "tmp" +#define DEFAULT_DB_LG_DIR DEFAULT_DBENV_HOME LDAP_DIRSEP "log" +#define DEFAULT_DB_DATA_DIR DEFAULT_DBENV_HOME LDAP_DIRSEP "data" struct bdb_dbinfo { DB_ENV *bdi_dbenv; @@ -31,8 +31,9 @@ struct bdb_dbinfo { u_int32_t bdi_dbenv_xflags; /* extra flags */ int bdi_dbenv_mode; - slap_mask_t bdi_db_mode; - char *bdi_db_directory; + char *bdi_db_tmp_dir; + char *bdi_db_lg_dir; + char *bdi_db_data_dir; }; LDAP_END_DECL diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index a31a5f62a1..c19bbdca99 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -146,10 +146,12 @@ bdb_back_db_init( /* DBEnv parameters */ bdi->bdi_dbenv_home = ch_strdup( DEFAULT_DBENV_HOME ); bdi->bdi_dbenv_xflags = 0; - bdi->bdi_dbenv_mode = DEFAULT_DBENV_MODE; + bdi->bdi_dbenv_mode = DEFAULT_MODE; /* default database directories */ - bdi->bdi_db_directory = ch_strdup( DEFAULT_DB_DIRECTORY ); + bdi->bdi_db_tmp_dir = ch_strdup( DEFAULT_DB_TMP_DIR ); + bdi->bdi_db_lg_dir = ch_strdup( DEFAULT_DB_LG_DIR ); + bdi->bdi_db_data_dir = ch_strdup( DEFAULT_DB_DATA_DIR ); be->be_private = bdi; return 0; @@ -174,14 +176,45 @@ bdb_back_db_open( return rc; } + flags = DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN | + DB_CREATE | DB_RECOVER | DB_THREAD; + #ifdef SLAPD_BDB_PRIVATE - flags = DB_INIT_LOCK | DB_INIT_TXN | - DB_PRIVATE | DB_RECOVER | DB_THREAD; + flags |= DB_PRIVATE; #else - flags = DB_INIT_LOCK | DB_INIT_TXN | DB_INIT_MPOOL | - DB_RECOVER | DB_THREAD; + flags |= DB_INIT_MPOOL; #endif + rc = bdi->bdi_dbenv->set_tmp_dir( bdi->bdi_dbenv, + bdi->bdi_db_tmp_dir ); + + if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "bdb_back_db_open: set_tmp_dir(%s) failed: %s (%d)\n", + bdi->bdi_db_tmp_dir, db_strerror(rc), rc ); + return rc; + } + + rc = bdi->bdi_dbenv->set_lg_dir( bdi->bdi_dbenv, + bdi->bdi_db_lg_dir ); + + if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "bdb_back_db_open: set_lg_dir(%s) failed: %s (%d)\n", + bdi->bdi_db_lg_dir, db_strerror(rc), rc ); + return rc; + } + + rc = bdi->bdi_dbenv->set_data_dir( bdi->bdi_dbenv, + bdi->bdi_db_data_dir ); + + if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "bdb_back_db_open: set_data_dir(%s) failed: %s (%d)\n", + bdi->bdi_db_data_dir, db_strerror(rc), rc ); + return rc; + } + rc = bdi->bdi_dbenv->open( bdi->bdi_dbenv, bdi->bdi_dbenv_home, flags | bdi->bdi_dbenv_xflags, @@ -189,8 +222,8 @@ bdb_back_db_open( if( rc != 0 ) { Debug( LDAP_DEBUG_ANY, - "bdb_back_db_open: db_open failed: %s (%d)\n", - db_strerror(rc), rc, 0 ); + "bdb_back_db_open: db_open(%s) failed: %s (%d)\n", + bdi->bdi_dbenv_home, db_strerror(rc), rc ); return rc; }