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>
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 bdb->bi_dbenv_xflags |= DB_TXN_NOT_DURABLE;
71 /* slapindex algorithm tuning */
72 } else if ( strcasecmp( argv[0], "linearindex" ) == 0 ) {
73 bdb->bi_linear_index = 1;
75 /* transaction checkpoint configuration */
76 } else if ( strcasecmp( argv[0], "checkpoint" ) == 0 ) {
78 fprintf( stderr, "%s: line %d: "
79 "missing parameters in \"checkpoint <kbyte> <min>\" line\n",
84 bdb->bi_txn_cp_kbyte = strtol( argv[1], NULL, 0 );
85 bdb->bi_txn_cp_min = strtol( argv[2], NULL, 0 );
87 /* lock detect configuration */
88 } else if ( strcasecmp( argv[0], "lockdetect" ) == 0 ) {
90 fprintf( stderr, "%s: line %d: "
91 "missing parameters in \"lockDetect <policy>\" line\n",
96 if( strcasecmp( argv[1], "default" ) == 0 ) {
97 bdb->bi_lock_detect = DB_LOCK_DEFAULT;
99 } else if( strcasecmp( argv[1], "oldest" ) == 0 ) {
100 bdb->bi_lock_detect = DB_LOCK_OLDEST;
102 } else if( strcasecmp( argv[1], "random" ) == 0 ) {
103 bdb->bi_lock_detect = DB_LOCK_RANDOM;
105 } else if( strcasecmp( argv[1], "youngest" ) == 0 ) {
106 bdb->bi_lock_detect = DB_LOCK_YOUNGEST;
108 } else if( strcasecmp( argv[1], "fewest" ) == 0 ) {
109 bdb->bi_lock_detect = DB_LOCK_MINLOCKS;
112 fprintf( stderr, "%s: line %d: "
113 "bad policy (%s) in \"lockDetect <policy>\" line\n",
114 fname, lineno, argv[1] );
118 /* mode with which to create new database files */
119 } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
121 fprintf( stderr, "%s: line %d: "
122 "missing mode in \"mode <mode>\" line\n",
126 bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 );
128 /* attribute to index */
129 } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
132 fprintf( stderr, "%s: line %d: "
133 "missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
136 } else if ( argc > 3 ) {
137 fprintf( stderr, "%s: line %d: "
138 "extra junk after \"index <attr> [pres,eq,approx,sub]\" "
142 rc = bdb_attr_index_config( bdb, fname, lineno, argc - 1, &argv[1] );
144 if( rc != LDAP_SUCCESS ) return 1;
146 /* unique key for shared memory regions */
147 } else if ( strcasecmp( argv[0], "shm_key" ) == 0 ) {
150 "%s: line %d: missing key in \"shm_key <key>\" line\n",
154 bdb->bi_shm_key = atoi( argv[1] );
156 /* size of the cache in entries */
157 } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) {
160 "%s: line %d: missing size in \"cachesize <size>\" line\n",
164 bdb->bi_cache.c_maxsize = atoi( argv[1] );
166 /* depth of search stack cache in units of (IDL)s */
167 } else if ( strcasecmp( argv[0], "searchstack" ) == 0 ) {
170 "%s: line %d: missing depth in \"searchstack <depth>\" line\n",
174 bdb->bi_search_stack_depth = atoi( argv[1] );
175 if ( bdb->bi_search_stack_depth < MINIMUM_SEARCH_STACK_DEPTH ) {
177 "%s: line %d: depth %d too small, using %d\n",
178 fname, lineno, bdb->bi_search_stack_depth,
179 MINIMUM_SEARCH_STACK_DEPTH );
180 bdb->bi_search_stack_depth = MINIMUM_SEARCH_STACK_DEPTH;
183 /* size of the IDL cache in entries */
184 } else if ( strcasecmp( argv[0], "idlcachesize" ) == 0 ) {
187 "%s: line %d: missing size in \"idlcachesize <size>\" line\n",
191 if ( !( slapMode & SLAP_TOOL_MODE ) )
192 bdb->bi_idl_cache_max_size = atoi( argv[1] );
193 } else if ( strcasecmp( argv[0], "sessionlog" ) == 0 ) {
194 int se_id = 0, se_size = 0;
195 struct slap_session_entry *sent;
197 Debug( LDAP_DEBUG_ANY,
198 "%s: line %d: missing arguments in \"sessionlog <id> <size>\""
199 " line\n", fname, lineno, 0 );
203 se_id = atoi( argv[1] );
205 if ( se_id < 0 || se_id > 999 ) {
206 Debug( LDAP_DEBUG_ANY,
207 "%s: line %d: session log id %d is out of range [0..999]\n",
208 fname, lineno , se_id );
212 se_size = atoi( argv[2] );
214 Debug( LDAP_DEBUG_ANY,
215 "%s: line %d: session log size %d is negative\n",
216 fname, lineno , se_size );
220 LDAP_LIST_FOREACH( sent, &bdb->bi_session_list, se_link ) {
221 if ( sent->se_id == se_id ) {
222 Debug( LDAP_DEBUG_ANY,
223 "%s: line %d: session %d already exists\n",
224 fname, lineno , se_id );
228 sent = (struct slap_session_entry *) ch_calloc( 1,
229 sizeof( struct slap_session_entry ));
231 sent->se_size = se_size;
232 LDAP_LIST_INSERT_HEAD( &bdb->bi_session_list, sent, se_link );
236 return SLAP_CONF_UNKNOWN;