1 /* config.c - bdb backend configuration file routine */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2005 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
20 #include <ac/string.h>
25 # define SLAP_BDB_ALLOW_DIRTY_READ
36 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
39 fprintf( stderr, "%s: line %d: "
40 "bdb database info is null!\n",
45 /* directory is the DB_HOME */
46 if ( strcasecmp( argv[0], "directory" ) == 0 ) {
48 fprintf( stderr, "%s: line %d: "
49 "missing dir in \"directory <dir>\" line\n",
53 if ( bdb->bi_dbenv_home ) {
54 free( bdb->bi_dbenv_home );
56 bdb->bi_dbenv_home = ch_strdup( argv[1] );
58 #ifdef SLAP_BDB_ALLOW_DIRTY_READ
59 } else if ( strcasecmp( argv[0], "dirtyread" ) == 0 ) {
60 bdb->bi_db_opflags |= DB_DIRTY_READ;
62 /* transaction logging configuration */
63 } else if ( strcasecmp( argv[0], "dbnosync" ) == 0 ) {
64 bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC;
66 /* slapadd/slapindex logging configuration */
67 } else if ( strcasecmp( argv[0], "fasttool" ) == 0 ) {
68 if ( slapMode & SLAP_TOOL_MODE )
69 #if DB_VERSION_FULL >= 0x04030015
70 bdb->bi_dbenv_xflags |= DB_LOG_INMEMORY;
72 bdb->bi_dbenv_xflags |= DB_TXN_NOT_DURABLE;
75 /* slapindex algorithm tuning */
76 } else if ( strcasecmp( argv[0], "linearindex" ) == 0 ) {
77 bdb->bi_linear_index = 1;
79 /* transaction checkpoint configuration */
80 } else if ( strcasecmp( argv[0], "checkpoint" ) == 0 ) {
82 fprintf( stderr, "%s: line %d: "
83 "missing parameters in \"checkpoint <kbyte> <min>\" line\n",
88 bdb->bi_txn_cp_kbyte = strtol( argv[1], NULL, 0 );
89 bdb->bi_txn_cp_min = strtol( argv[2], NULL, 0 );
91 /* lock detect configuration */
92 } else if ( strcasecmp( argv[0], "lockdetect" ) == 0 ) {
94 fprintf( stderr, "%s: line %d: "
95 "missing parameters in \"lockDetect <policy>\" line\n",
100 if( strcasecmp( argv[1], "default" ) == 0 ) {
101 bdb->bi_lock_detect = DB_LOCK_DEFAULT;
103 } else if( strcasecmp( argv[1], "oldest" ) == 0 ) {
104 bdb->bi_lock_detect = DB_LOCK_OLDEST;
106 } else if( strcasecmp( argv[1], "random" ) == 0 ) {
107 bdb->bi_lock_detect = DB_LOCK_RANDOM;
109 } else if( strcasecmp( argv[1], "youngest" ) == 0 ) {
110 bdb->bi_lock_detect = DB_LOCK_YOUNGEST;
112 } else if( strcasecmp( argv[1], "fewest" ) == 0 ) {
113 bdb->bi_lock_detect = DB_LOCK_MINLOCKS;
116 fprintf( stderr, "%s: line %d: "
117 "bad policy (%s) in \"lockDetect <policy>\" line\n",
118 fname, lineno, argv[1] );
122 /* mode with which to create new database files */
123 } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
125 fprintf( stderr, "%s: line %d: "
126 "missing mode in \"mode <mode>\" line\n",
130 bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 );
132 /* attribute to index */
133 } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
136 fprintf( stderr, "%s: line %d: "
137 "missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
140 } else if ( argc > 3 ) {
141 fprintf( stderr, "%s: line %d: "
142 "extra junk after \"index <attr> [pres,eq,approx,sub]\" "
146 rc = bdb_attr_index_config( bdb, fname, lineno, argc - 1, &argv[1] );
148 if( rc != LDAP_SUCCESS ) return 1;
150 /* unique key for shared memory regions */
151 } else if ( strcasecmp( argv[0], "shm_key" ) == 0 ) {
154 "%s: line %d: missing key in \"shm_key <key>\" line\n",
158 bdb->bi_shm_key = atoi( argv[1] );
160 /* size of the cache in entries */
161 } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) {
164 "%s: line %d: missing size in \"cachesize <size>\" line\n",
168 bdb->bi_cache.c_maxsize = atoi( argv[1] );
170 /* depth of search stack cache in units of (IDL)s */
171 } else if ( strcasecmp( argv[0], "searchstack" ) == 0 ) {
174 "%s: line %d: missing depth in \"searchstack <depth>\" line\n",
178 bdb->bi_search_stack_depth = atoi( argv[1] );
179 if ( bdb->bi_search_stack_depth < MINIMUM_SEARCH_STACK_DEPTH ) {
181 "%s: line %d: depth %d too small, using %d\n",
182 fname, lineno, bdb->bi_search_stack_depth,
183 MINIMUM_SEARCH_STACK_DEPTH );
184 bdb->bi_search_stack_depth = MINIMUM_SEARCH_STACK_DEPTH;
187 /* size of the IDL cache in entries */
188 } else if ( strcasecmp( argv[0], "idlcachesize" ) == 0 ) {
191 "%s: line %d: missing size in \"idlcachesize <size>\" line\n",
195 if ( !( slapMode & SLAP_TOOL_MODE ) )
196 bdb->bi_idl_cache_max_size = atoi( argv[1] );
200 return SLAP_CONF_UNKNOWN;