mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-24 13:24:56 +08:00
Reply on DB_CONFIG for tuning...
This commit is contained in:
parent
50714d2d48
commit
7ab0916488
@ -23,11 +23,11 @@ LDAP_BEGIN_DECL
|
||||
|
||||
#define DEFAULT_MODE 0600
|
||||
|
||||
#define DEFAULT_DBENV_HOME LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb"
|
||||
#define BDB_DBENV_HOME LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb"
|
||||
|
||||
#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"
|
||||
#define BDB_TMP_SUBDIR LDAP_DIRSEP "tmp"
|
||||
#define BDB_LG_SUBDIR LDAP_DIRSEP "log"
|
||||
#define BDB_DATA_SUBDIR LDAP_DIRSEP "data"
|
||||
|
||||
#define BDB_NEXTID 0
|
||||
#define BDB_ENTRIES 1
|
||||
@ -40,19 +40,12 @@ struct bdb_db_info {
|
||||
struct bdb_info {
|
||||
DB_ENV *bi_dbenv;
|
||||
|
||||
/* DB_env parameters */
|
||||
/* DB_ENV parameters */
|
||||
/* The DB_ENV can be tuned via DB_CONFIG */
|
||||
char *bi_dbenv_home;
|
||||
u_int32_t bi_dbenv_xflags; /* extra flags */
|
||||
int bi_dbenv_mode;
|
||||
|
||||
int bi_tx_max;
|
||||
|
||||
char *bi_db_tmp_dir;
|
||||
char *bi_db_lg_dir;
|
||||
char *bi_db_data_dir;
|
||||
|
||||
ID *bi_lastid;
|
||||
|
||||
int bi_ndatabases;
|
||||
struct bdb_db_info **bdi_databases;
|
||||
};
|
||||
|
@ -43,17 +43,10 @@ bi_back_db_init( Backend *be )
|
||||
bdb = (struct bdb_info *) ch_calloc( 1, sizeof(struct bdb_info) );
|
||||
|
||||
/* DBEnv parameters */
|
||||
bdb->bi_dbenv_home = ch_strdup( DEFAULT_DBENV_HOME );
|
||||
bdb->bi_dbenv_home = ch_strdup( BDB_DBENV_HOME );
|
||||
bdb->bi_dbenv_xflags = 0;
|
||||
bdb->bi_dbenv_mode = DEFAULT_MODE;
|
||||
|
||||
/* default database directories */
|
||||
bdb->bi_db_tmp_dir = ch_strdup( DEFAULT_DB_TMP_DIR );
|
||||
bdb->bi_db_lg_dir = ch_strdup( DEFAULT_DB_LG_DIR );
|
||||
bdb->bi_db_data_dir = ch_strdup( DEFAULT_DB_DATA_DIR );
|
||||
|
||||
bdb->bi_lastid = NOID;
|
||||
|
||||
be->be_private = bdb;
|
||||
return 0;
|
||||
}
|
||||
@ -64,7 +57,6 @@ bi_back_db_open( BackendDB *be )
|
||||
int rc;
|
||||
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
|
||||
u_int32_t flags;
|
||||
|
||||
/* we should check existance of dbenv_home and db_directory */
|
||||
|
||||
rc = db_env_create( &bdb->bi_dbenv, 0 );
|
||||
@ -87,42 +79,40 @@ bi_back_db_open( BackendDB *be )
|
||||
bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0] );
|
||||
bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
|
||||
|
||||
if( bdb->bi_tx_max ) {
|
||||
rc = bdb->bi_dbenv->set_tx_max( bdb->bi_dbenv,
|
||||
bdb->bi_tx_max );
|
||||
{
|
||||
char dir[MAXPATHLEN];
|
||||
size_t len = strlen( bdb->bi_dbenv_home );
|
||||
|
||||
strcpy( dir, bdb->bi_dbenv_home );
|
||||
strcat( &dir[len], BDB_TMP_SUBDIR );
|
||||
|
||||
rc = bdb->bi_dbenv->set_tmp_dir( bdb->bi_dbenv, dir );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bi_back_db_open: set_tx_max(%d) failed: %s (%d)\n",
|
||||
bdb->bi_tx_max, db_strerror(rc), rc );
|
||||
"bi_back_db_open: set_tmp_dir(%s) failed: %s (%d)\n",
|
||||
dir, db_strerror(rc), rc );
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
rc = bdb->bi_dbenv->set_tmp_dir( bdb->bi_dbenv,
|
||||
bdb->bi_db_tmp_dir );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bi_back_db_open: set_tmp_dir(%s) failed: %s (%d)\n",
|
||||
bdb->bi_db_tmp_dir, db_strerror(rc), rc );
|
||||
return rc;
|
||||
}
|
||||
strcat( &dir[len], BDB_LG_SUBDIR );
|
||||
|
||||
rc = bdb->bi_dbenv->set_lg_dir( bdb->bi_dbenv,
|
||||
bdb->bi_db_lg_dir );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bi_back_db_open: set_lg_dir(%s) failed: %s (%d)\n",
|
||||
bdb->bi_db_lg_dir, db_strerror(rc), rc );
|
||||
return rc;
|
||||
}
|
||||
rc = bdb->bi_dbenv->set_lg_dir( bdb->bi_dbenv, dir );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bi_back_db_open: set_lg_dir(%s) failed: %s (%d)\n",
|
||||
dir, db_strerror(rc), rc );
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = bdb->bi_dbenv->set_data_dir( bdb->bi_dbenv,
|
||||
bdb->bi_db_data_dir );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bi_back_db_open: set_data_dir(%s) failed: %s (%d)\n",
|
||||
bdb->bi_db_data_dir, db_strerror(rc), rc );
|
||||
return rc;
|
||||
strcat( &dir[len], BDB_DATA_SUBDIR );
|
||||
|
||||
rc = bdb->bi_dbenv->set_data_dir( bdb->bi_dbenv, dir );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bi_back_db_open: set_data_dir(%s) failed: %s (%d)\n",
|
||||
dir, db_strerror(rc), rc );
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
|
||||
@ -136,6 +126,8 @@ bi_back_db_open( BackendDB *be )
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* we now need to open (and create) all database */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user