1 /* config.c - bdb backend configuration file routine */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2004 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>
26 # define SLAP_BDB_ALLOW_DIRTY_READ
37 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
40 fprintf( stderr, "%s: line %d: "
41 "bdb database info is null!\n",
46 /* directory is the DB_HOME */
47 if ( strcasecmp( argv[0], "directory" ) == 0 ) {
49 fprintf( stderr, "%s: line %d: "
50 "missing dir in \"directory <dir>\" line\n",
54 if ( bdb->bi_dbenv_home ) {
55 free( bdb->bi_dbenv_home );
57 bdb->bi_dbenv_home = ch_strdup( argv[1] );
59 #ifdef SLAP_BDB_ALLOW_DIRTY_READ
60 } else if ( strcasecmp( argv[0], "dirtyread" ) == 0 ) {
61 bdb->bi_db_opflags |= DB_DIRTY_READ;
63 /* transaction logging configuration */
64 } else if ( strcasecmp( argv[0], "dbnosync" ) == 0 ) {
65 bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC;
67 /* slapadd/slapindex logging configuration */
68 } else if ( strcasecmp( argv[0], "fasttool" ) == 0 ) {
69 if ( slapMode & SLAP_TOOL_MODE )
70 bdb->bi_dbenv_xflags |= DB_TXN_NOT_DURABLE;
72 /* slapindex algorithm tuning */
73 } else if ( strcasecmp( argv[0], "linearindex" ) == 0 ) {
74 bdb->bi_linear_index = 1;
76 /* transaction checkpoint configuration */
77 } else if ( strcasecmp( argv[0], "checkpoint" ) == 0 ) {
79 fprintf( stderr, "%s: line %d: "
80 "missing parameters in \"checkpoint <kbyte> <min>\" line\n",
85 bdb->bi_txn_cp_kbyte = strtol( argv[1], NULL, 0 );
86 bdb->bi_txn_cp_min = strtol( argv[2], NULL, 0 );
88 /* lock detect configuration */
89 } else if ( strcasecmp( argv[0], "lockdetect" ) == 0 ) {
91 fprintf( stderr, "%s: line %d: "
92 "missing parameters in \"lockDetect <policy>\" line\n",
97 if( strcasecmp( argv[1], "default" ) == 0 ) {
98 bdb->bi_lock_detect = DB_LOCK_DEFAULT;
100 } else if( strcasecmp( argv[1], "oldest" ) == 0 ) {
101 bdb->bi_lock_detect = DB_LOCK_OLDEST;
103 } else if( strcasecmp( argv[1], "random" ) == 0 ) {
104 bdb->bi_lock_detect = DB_LOCK_RANDOM;
106 } else if( strcasecmp( argv[1], "youngest" ) == 0 ) {
107 bdb->bi_lock_detect = DB_LOCK_YOUNGEST;
109 } else if( strcasecmp( argv[1], "fewest" ) == 0 ) {
110 bdb->bi_lock_detect = DB_LOCK_MINLOCKS;
113 fprintf( stderr, "%s: line %d: "
114 "bad policy (%s) in \"lockDetect <policy>\" line\n",
115 fname, lineno, argv[1] );
119 /* mode with which to create new database files */
120 } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
122 fprintf( stderr, "%s: line %d: "
123 "missing mode in \"mode <mode>\" line\n",
127 bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 );
129 /* attribute to index */
130 } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
133 fprintf( stderr, "%s: line %d: "
134 "missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
137 } else if ( argc > 3 ) {
138 fprintf( stderr, "%s: line %d: "
139 "extra junk after \"index <attr> [pres,eq,approx,sub]\" "
143 rc = bdb_attr_index_config( bdb, fname, lineno, argc - 1, &argv[1] );
145 if( rc != LDAP_SUCCESS ) return 1;
147 /* unique key for shared memory regions */
148 } else if ( strcasecmp( argv[0], "shm_key" ) == 0 ) {
151 "%s: line %d: missing key in \"shm_key <key>\" line\n",
155 bdb->bi_shm_key = atoi( argv[1] );
157 /* size of the cache in entries */
158 } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) {
161 "%s: line %d: missing size in \"cachesize <size>\" line\n",
165 bdb->bi_cache.c_maxsize = atoi( argv[1] );
167 /* depth of search stack cache in units of (IDL)s */
168 } else if ( strcasecmp( argv[0], "searchstack" ) == 0 ) {
171 "%s: line %d: missing depth in \"searchstack <depth>\" line\n",
175 bdb->bi_search_stack_depth = atoi( argv[1] );
176 if ( bdb->bi_search_stack_depth < MINIMUM_SEARCH_STACK_DEPTH ) {
178 "%s: line %d: depth %d too small, using %d\n",
179 fname, lineno, bdb->bi_search_stack_depth,
180 MINIMUM_SEARCH_STACK_DEPTH );
181 bdb->bi_search_stack_depth = MINIMUM_SEARCH_STACK_DEPTH;
184 /* size of the IDL cache in entries */
185 } else if ( strcasecmp( argv[0], "idlcachesize" ) == 0 ) {
188 "%s: line %d: missing size in \"idlcachesize <size>\" line\n",
192 if ( !( slapMode & SLAP_TOOL_MODE ) )
193 bdb->bi_idl_cache_max_size = atoi( argv[1] );
194 } else if ( strcasecmp( argv[0], "sessionlog" ) == 0 ) {
195 int se_id = 0, se_size = 0;
196 struct slap_session_entry *sent;
199 LDAP_LOG( CONFIG, CRIT,
200 "%s: line %d: missing arguments in \"sessionlog <id> <size>\""
201 " line.\n", fname, lineno , 0 );
203 Debug( LDAP_DEBUG_ANY,
204 "%s: line %d: missing arguments in \"sessionlog <id> <size>\""
205 " line\n", fname, lineno, 0 );
210 se_id = atoi( argv[1] );
212 if ( se_id < 0 || se_id > 999 ) {
214 LDAP_LOG( CONFIG, CRIT,
215 "%s: line %d: session log id %d is out of range [0..999]\n",
216 fname, lineno , se_id );
218 Debug( LDAP_DEBUG_ANY,
219 "%s: line %d: session log id %d is out of range [0..999]\n",
220 fname, lineno , se_id );
225 se_size = atoi( argv[2] );
228 LDAP_LOG( CONFIG, CRIT,
229 "%s: line %d: session log size %d is negative\n",
230 fname, lineno , se_size );
232 Debug( LDAP_DEBUG_ANY,
233 "%s: line %d: session log size %d is negative\n",
234 fname, lineno , se_size );
239 LDAP_LIST_FOREACH( sent, &bdb->bi_session_list, se_link ) {
240 if ( sent->se_id == se_id ) {
242 LDAP_LOG( CONFIG, CRIT,
243 "%s: line %d: session %d already exists\n",
244 fname, lineno , se_id );
246 Debug( LDAP_DEBUG_ANY,
247 "%s: line %d: session %d already exists\n",
248 fname, lineno , se_id );
253 sent = (struct slap_session_entry *) ch_calloc( 1,
254 sizeof( struct slap_session_entry ));
256 sent->se_size = se_size;
257 LDAP_LIST_INSERT_HEAD( &bdb->bi_session_list, sent, se_link );
261 return SLAP_CONF_UNKNOWN;