]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/config.c
Add hdb symbols, make sure only one indexer runs
[openldap] / servers / slapd / back-bdb / config.c
1 /* config.c - bdb backend configuration file routine */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 2000-2005 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
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>.
15  */
16
17 #include "portable.h"
18
19 #include <stdio.h>
20 #include <ac/string.h>
21
22 #include "back-bdb.h"
23
24 #include "config.h"
25
26 #include "lutil.h"
27 #include "ldap_rq.h"
28
29 #ifdef DB_DIRTY_READ
30 #       define  SLAP_BDB_ALLOW_DIRTY_READ
31 #endif
32
33 #define bdb_cf_oc                       BDB_SYMBOL(cf_oc)
34 #define bdb_cf_gen                      BDB_SYMBOL(cf_gen)
35 #define bdb_cf_cleanup          BDB_SYMBOL(cf_cleanup)
36 #define bdb_checkpoint          BDB_SYMBOL(checkpoint)
37 #define bdb_online_index        BDB_SYMBOL(online_index)
38
39 static ObjectClass *bdb_oc;
40
41 static ConfigDriver bdb_cf_oc, bdb_cf_gen;
42
43 enum {
44         BDB_CHKPT = 1,
45         BDB_CONFIG,
46         BDB_DIRECTORY,
47         BDB_NOSYNC,
48         BDB_DIRTYR,
49         BDB_INDEX,
50         BDB_LOCKD,
51         BDB_SSTACK
52 };
53
54 static ConfigTable bdbcfg[] = {
55         { "", "", 0, 0, 0, ARG_MAGIC,
56                 bdb_cf_oc, NULL, NULL, NULL },
57         { "directory", "dir", 2, 2, 0, ARG_STRING|ARG_MAGIC|BDB_DIRECTORY,
58                 bdb_cf_gen, "( OLcfgDbAt:0.1 NAME 'olcDbDirectory' "
59                         "DESC 'Directory for database content' "
60                         "EQUALITY caseIgnoreMatch "
61                         "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
62         { "cachesize", "size", 2, 2, 0, ARG_INT|ARG_OFFSET,
63                 (void *)offsetof(struct bdb_info, bi_cache.c_maxsize),
64                 "( OLcfgDbAt:1.1 NAME 'olcDbCacheSize' "
65                         "DESC 'Entry cache size in entries' "
66                         "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
67         { "checkpoint", "kbyte> <min", 3, 3, 0, ARG_MAGIC|BDB_CHKPT,
68                 bdb_cf_gen, "( OLcfgDbAt:1.2 NAME 'olcDbCheckpoint' "
69                         "DESC 'Database checkpoint interval in kbytes and minutes' "
70                         "SYNTAX OMsDirectoryString SINGLE-VALUE )",NULL, NULL },
71         { "dbconfig", "DB_CONFIG setting", 3, 0, 0, ARG_MAGIC|BDB_CONFIG,
72                 bdb_cf_gen, "( OLcfgDbAt:1.3 NAME 'olcDbConfig' "
73                         "DESC 'BerkeleyDB DB_CONFIG configuration directives' "
74                         "SYNTAX OMsDirectoryString )",NULL, NULL },
75         { "dbnosync", NULL, 1, 2, 0, ARG_ON_OFF|ARG_MAGIC|BDB_NOSYNC,
76                 bdb_cf_gen, "( OLcfgDbAt:1.4 NAME 'olcDbNoSync' "
77                         "DESC 'Disable synchronous database writes' "
78                         "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
79         { "dirtyread", NULL, 1, 2, 0,
80 #ifdef SLAP_BDB_ALLOW_DIRTY_READ
81                 ARG_ON_OFF|ARG_MAGIC|BDB_DIRTYR, bdb_cf_gen,
82 #else
83                 ARG_IGNORED, NULL,
84 #endif
85                 "( OLcfgDbAt:1.5 NAME 'olcDbDirtyRead' "
86                 "DESC 'Allow reads of uncommitted data' "
87                 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
88         { "idlcachesize", "size", 2, 2, 0, ARG_INT|ARG_OFFSET,
89                 (void *)offsetof(struct bdb_info,bi_idl_cache_max_size),
90                 "( OLcfgDbAt:1.6 NAME 'olcDbIDLcacheSize' "
91                 "DESC 'IDL cache size in IDLs' "
92                 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
93         { "index", "attr> <[pres,eq,approx,sub]", 2, 3, 0, ARG_MAGIC|BDB_INDEX,
94                 bdb_cf_gen, "( OLcfgDbAt:0.2 NAME 'olcDbIndex' "
95                 "DESC 'Attribute index parameters' "
96                 "EQUALITY caseIgnoreMatch "
97                 "SYNTAX OMsDirectoryString )", NULL, NULL },
98         { "linearindex", NULL, 1, 2, 0, ARG_ON_OFF|ARG_OFFSET,
99                 (void *)offsetof(struct bdb_info, bi_linear_index), 
100                 "( OLcfgDbAt:1.7 NAME 'olcDbLinearIndex' "
101                 "DESC 'Index attributes one at a time' "
102                 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
103         { "lockdetect", "policy", 2, 2, 0, ARG_MAGIC|BDB_LOCKD,
104                 bdb_cf_gen, "( OLcfgDbAt:1.8 NAME 'olcDbLockDetect' "
105                 "DESC 'Deadlock detection algorithm' "
106                 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
107         { "mode", "mode", 2, 2, 0, ARG_INT|ARG_OFFSET,
108                 (void *)offsetof(struct bdb_info, bi_dbenv_mode),
109                 "( OLcfgDbAt:0.3 NAME 'olcDbMode' "
110                 "DESC 'Unix permissions of database files' "
111                 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
112         { "searchstack", "depth", 2, 2, 0, ARG_INT|ARG_MAGIC|BDB_SSTACK,
113                 bdb_cf_gen, "( OLcfgDbAt:1.9 NAME 'olcDbSearchStack' "
114                 "DESC 'Depth of search stack in IDLs' "
115                 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
116         { "shm_key", "key", 2, 2, 0, ARG_INT|ARG_OFFSET,
117                 (void *)offsetof(struct bdb_info, bi_shm_key), 
118                 "( OLcfgDbAt:1.10 NAME 'olcDbShmKey' "
119                 "DESC 'Key for shared memory region' "
120                 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
121         { NULL, NULL, 0, 0, 0, ARG_IGNORED,
122                 NULL, NULL, NULL, NULL }
123 };
124
125 static ConfigOCs bdbocs[] = {
126         { "( OLcfgDbOc:1.1 "
127                 "NAME 'olcBdbConfig' "
128                 "DESC 'BDB backend configuration' "
129                 "SUP olcDatabaseConfig "
130                 "MUST olcDbDirectory "
131                 "MAY ( olcDbCacheSize $ olcDbCheckpoint $ olcDbConfig $ "
132                 "olcDbNoSync $ olcDbDirtyRead $ olcDbIDLcacheSize $ "
133                 "olcDbIndex $ olcDbLinearIndex $ olcDbLockDetect $ "
134                 "olcDbMode $ olcDbSearchStack $ olcDbShmKey ) )",
135                         Cft_Database, &bdb_oc },
136         { NULL, 0, NULL }
137 };
138
139 static int
140 bdb_cf_oc(ConfigArgs *c)
141 {
142         if ( c->op == SLAP_CONFIG_EMIT ) {
143                 value_add_one( &c->rvalue_vals, &bdb_oc->soc_cname );
144                 return 0;
145         }
146         return 1;
147 }
148
149 static slap_verbmasks bdb_lockd[] = {
150         { BER_BVC("default"), DB_LOCK_DEFAULT },
151         { BER_BVC("oldest"), DB_LOCK_OLDEST },
152         { BER_BVC("random"), DB_LOCK_RANDOM },
153         { BER_BVC("youngest"), DB_LOCK_YOUNGEST },
154         { BER_BVC("fewest"), DB_LOCK_MINLOCKS },
155         { BER_BVNULL, 0 }
156 };
157
158 /* perform periodic checkpoints */
159 static void *
160 bdb_checkpoint( void *ctx, void *arg )
161 {
162         struct re_s *rtask = arg;
163         struct bdb_info *bdb = rtask->arg;
164         
165         TXN_CHECKPOINT( bdb->bi_dbenv, bdb->bi_txn_cp_kbyte,
166                 bdb->bi_txn_cp_min, 0 );
167         ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
168         ldap_pvt_runqueue_stoptask( &slapd_rq, rtask );
169         ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
170         return NULL;
171 }
172
173 /* reindex entries on the fly */
174 static void *
175 bdb_online_index( void *ctx, void *arg )
176 {
177         struct re_s *rtask = arg;
178         BackendDB *be = rtask->arg;
179         struct bdb_info *bdb = be->be_private;
180
181         Connection conn = {0};
182         char opbuf[OPERATION_BUFFER_SIZE];
183         Operation *op = (Operation *)opbuf;
184
185         DBC *curs;
186         DBT key, data;
187         DB_TXN *txn;
188         DB_LOCK lock;
189         u_int32_t locker;
190         ID id, nid;
191         EntryInfo *ei;
192         int rc, getnext = 1;
193
194         connection_fake_init( &conn, op, ctx );
195
196         op->o_bd = be;
197
198         DBTzero( &key );
199         DBTzero( &data );
200         
201         id = 1;
202         key.data = &nid;
203         key.size = key.ulen = sizeof(ID);
204         key.flags = DB_DBT_USERMEM;
205
206         data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
207         data.dlen = data.ulen = 0;
208
209         while ( 1 ) {
210                 if ( slapd_shutdown )
211                         break;
212
213                 rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &txn, bdb->bi_db_opflags );
214                 if ( rc ) 
215                         break;
216                 locker = TXN_ID( txn );
217                 if ( getnext ) {
218                         getnext = 0;
219                         BDB_ID2DISK( id, &nid );
220                         rc = bdb->bi_id2entry->bdi_db->cursor(
221                                 bdb->bi_id2entry->bdi_db, txn, &curs, bdb->bi_db_opflags );
222                         if ( rc ) {
223                                 TXN_ABORT( txn );
224                                 break;
225                         }
226                         rc = curs->c_get( curs, &key, &data, DB_SET_RANGE );
227                         curs->c_close( curs );
228                         if ( rc ) {
229                                 TXN_ABORT( txn );
230                                 if ( rc == DB_NOTFOUND )
231                                         rc = 0;
232                                 if ( rc == DB_LOCK_DEADLOCK ) {
233                                         ldap_pvt_thread_yield();
234                                         continue;
235                                 }
236                                 break;
237                         }
238                         BDB_DISK2ID( &nid, &id );
239                 }
240
241                 ei = NULL;
242                 rc = bdb_cache_find_id( op, txn, id, &ei, 0, locker, &lock );
243                 if ( rc ) {
244                         TXN_ABORT( txn );
245                         if ( rc == DB_LOCK_DEADLOCK ) {
246                                 ldap_pvt_thread_yield();
247                                 continue;
248                         }
249                         if ( rc == DB_NOTFOUND ) {
250                                 id++;
251                                 getnext = 1;
252                                 continue;
253                         }
254                         break;
255                 }
256                 if ( ei->bei_e ) {
257                         rc = bdb_index_entry( op, txn, BDB_INDEX_UPDATE_OP, ei->bei_e );
258                         if ( rc == DB_LOCK_DEADLOCK ) {
259                                 TXN_ABORT( txn );
260                                 ldap_pvt_thread_yield();
261                                 continue;
262                         }
263                         if ( rc == 0 ) {
264                                 rc = TXN_COMMIT( txn, 0 );
265                                 txn = NULL;
266                         }
267                         if ( rc )
268                                 break;
269                 }
270                 id++;
271                 getnext = 1;
272         }
273 out:
274         ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
275         ldap_pvt_runqueue_stoptask( &slapd_rq, rtask );
276         bdb->bi_index_task = NULL;
277         ldap_pvt_runqueue_remove( &slapd_rq, rtask );
278         ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
279
280         return NULL;
281 }
282
283 /* Cleanup loose ends after Modify completes */
284 static int
285 bdb_cf_cleanup( ConfigArgs *c )
286 {
287         struct bdb_info *bdb = c->be->be_private;
288         int rc = 0;
289
290         if ( bdb->bi_flags & BDB_UPD_CONFIG ) {
291                 if ( bdb->bi_db_config ) {
292                         int i;
293                         FILE *f = fopen( bdb->bi_db_config_path, "w" );
294                         if ( f ) {
295                                 for (i=0; bdb->bi_db_config[i].bv_val; i++)
296                                         fprintf( f, "%s\n", bdb->bi_db_config[i].bv_val );
297                                 fclose( f );
298                         }
299                 } else {
300                         unlink( bdb->bi_db_config_path );
301                 }
302                 bdb->bi_flags ^= BDB_UPD_CONFIG;
303         }
304
305         if ( bdb->bi_flags & BDB_DEL_INDEX ) {
306                 bdb_attr_flush( bdb );
307                 bdb->bi_flags ^= BDB_DEL_INDEX;
308         }
309         
310         if ( bdb->bi_flags & BDB_RE_OPEN ) {
311                 bdb->bi_flags ^= BDB_RE_OPEN;
312                 rc = c->be->bd_info->bi_db_close( c->be );
313                 if ( rc == 0 )
314                         rc = c->be->bd_info->bi_db_open( c->be );
315                 /* If this fails, we need to restart */
316                 if ( rc ) {
317                         slapd_shutdown = 2;
318                         Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(bdb_cf_cleanup)
319                                 ": failed to reopen database, rc=%d", rc, 0, 0 );
320                 }
321         }
322         return rc;
323 }
324
325 static int
326 bdb_cf_gen(ConfigArgs *c)
327 {
328         struct bdb_info *bdb = c->be->be_private;
329         int rc;
330
331         if ( c->op == SLAP_CONFIG_EMIT ) {
332                 rc = 0;
333                 switch( c->type ) {
334                 case BDB_CHKPT:
335                         if (bdb->bi_txn_cp ) {
336                                 char buf[64];
337                                 struct berval bv;
338                                 bv.bv_len = sprintf( buf, "%d %d", bdb->bi_txn_cp_kbyte,
339                                         bdb->bi_txn_cp_min );
340                                 bv.bv_val = buf;
341                                 value_add_one( &c->rvalue_vals, &bv );
342                         } else{
343                                 rc = 1;
344                         }
345                         break;
346
347                 case BDB_DIRECTORY:
348                         if ( bdb->bi_dbenv_home ) {
349                                 c->value_string = ch_strdup( bdb->bi_dbenv_home );
350                         } else {
351                                 rc = 1;
352                         }
353                         break;
354
355                 case BDB_CONFIG:
356                         if ( bdb->bi_db_config ) {
357                                 int i;
358                                 struct berval bv;
359
360                                 bv.bv_val = c->log;
361                                 for (i=0; !BER_BVISNULL(&bdb->bi_db_config[i]); i++) {
362                                         bv.bv_len = sprintf( bv.bv_val, "{%d}%s", i,
363                                                 bdb->bi_db_config[i].bv_val );
364                                         value_add_one( &c->rvalue_vals, &bv );
365                                 }
366                         }
367                         if ( !c->rvalue_vals ) rc = 1;
368                         break;
369
370                 case BDB_NOSYNC:
371                         if ( bdb->bi_dbenv_xflags & DB_TXN_NOSYNC )
372                                 c->value_int = 1;
373                         break;
374                         
375                 case BDB_INDEX:
376                         bdb_attr_index_unparse( bdb, &c->rvalue_vals );
377                         if ( !c->rvalue_vals ) rc = 1;
378                         break;
379
380                 case BDB_LOCKD:
381                         rc = 1;
382                         if ( bdb->bi_lock_detect != DB_LOCK_DEFAULT ) {
383                                 int i;
384                                 for (i=0; !BER_BVISNULL(&bdb_lockd[i].word); i++) {
385                                         if ( bdb->bi_lock_detect == bdb_lockd[i].mask ) {
386                                                 value_add_one( &c->rvalue_vals, &bdb_lockd[i].word );
387                                                 rc = 0;
388                                                 break;
389                                         }
390                                 }
391                         }
392                         break;
393
394                 case BDB_SSTACK:
395                         c->value_int = bdb->bi_search_stack_depth;
396                         break;
397                 }
398                 return rc;
399         } else if ( c->op == LDAP_MOD_DELETE ) {
400                 rc = 0;
401                 switch( c->type ) {
402                 /* single-valued no-ops */
403                 case BDB_LOCKD:
404                 case BDB_SSTACK:
405                         break;
406
407                 case BDB_CHKPT:
408                         if ( bdb->bi_txn_cp_task ) {
409                                 struct re_s *re = bdb->bi_txn_cp_task;
410                                 bdb->bi_txn_cp_task = NULL;
411                                 if ( ldap_pvt_runqueue_isrunning( &slapd_rq, re ))
412                                         ldap_pvt_runqueue_stoptask( &slapd_rq, re );
413                                 ldap_pvt_runqueue_remove( &slapd_rq, re );
414                         }
415                         bdb->bi_txn_cp = 0;
416                         break;
417                 case BDB_CONFIG:
418                         if ( c->valx < 0 ) {
419                                 ber_bvarray_free( bdb->bi_db_config );
420                                 bdb->bi_db_config = NULL;
421                         } else {
422                                 int i = c->valx;
423                                 ch_free( bdb->bi_db_config[i].bv_val );
424                                 for (; bdb->bi_db_config[i].bv_val; i++)
425                                         bdb->bi_db_config[i] = bdb->bi_db_config[i+1];
426                         }
427                         bdb->bi_flags |= BDB_UPD_CONFIG;
428                         c->cleanup = bdb_cf_cleanup;
429                         break;
430                 case BDB_DIRECTORY:
431                         bdb->bi_flags |= BDB_RE_OPEN;
432                         bdb->bi_flags ^= BDB_HAS_CONFIG;
433                         ch_free( bdb->bi_dbenv_home );
434                         bdb->bi_dbenv_home = NULL;
435                         ch_free( bdb->bi_db_config_path );
436                         bdb->bi_db_config_path = NULL;
437                         c->cleanup = bdb_cf_cleanup;
438                         ldap_pvt_thread_pool_purgekey( bdb->bi_dbenv );
439                         ldap_pvt_thread_pool_purgekey( ((char *)bdb->bi_dbenv) + 1 );
440                         break;
441                 case BDB_NOSYNC:
442                         bdb->bi_dbenv->set_flags( bdb->bi_dbenv, DB_TXN_NOSYNC, 0 );
443                         break;
444                 case BDB_INDEX: {
445                         AttributeDescription *ad = NULL;
446                         struct berval bv, def = BER_BVC("default");
447                         char *ptr;
448                         const char *text;
449                         for (ptr = c->line; !isspace( *ptr ); ptr++);
450                         bv.bv_val = c->line;
451                         bv.bv_len = ptr - bv.bv_val;
452                         if ( bvmatch( &bv, &def )) {
453                                 bdb->bi_defaultmask = 0;
454                         } else {
455                                 slap_bv2ad( &bv, &ad, &text );
456                                 if ( ad ) {
457                                         AttrInfo *ai = bdb_attr_mask( bdb, ad );
458                                         ai->ai_indexmask |= BDB_INDEX_DELETING;
459                                         bdb->bi_flags |= BDB_DEL_INDEX;
460                                         c->cleanup = bdb_cf_cleanup;
461                                 }
462                         }
463                         }
464                         break;
465                 }
466                 return rc;
467         }
468
469         switch( c->type ) {
470         case BDB_CHKPT:
471                 bdb->bi_txn_cp = 1;
472                 bdb->bi_txn_cp_kbyte = strtol( c->argv[1], NULL, 0 );
473                 bdb->bi_txn_cp_min = strtol( c->argv[2], NULL, 0 );
474                 /* If we're in server mode and time-based checkpointing is enabled,
475                  * submit a task to perform periodic checkpoints.
476                  */
477                 if ((slapMode & SLAP_SERVER_MODE) && bdb->bi_txn_cp_min ) {
478                         struct re_s *re = bdb->bi_txn_cp_task;
479                         if ( re )
480                                 re->interval.tv_sec = bdb->bi_txn_cp_min * 60;
481                         else
482                                 bdb->bi_txn_cp_task = ldap_pvt_runqueue_insert( &slapd_rq,
483                                         bdb->bi_txn_cp_min * 60, bdb_checkpoint, bdb,
484                                         LDAP_XSTRING(bdb_checkpoint), c->be->be_suffix[0].bv_val );
485                 }
486                 break;
487
488         case BDB_CONFIG: {
489                 char *ptr = c->line + STRLENOF("dbconfig");
490                 struct berval bv;
491                 while (!isspace(*ptr)) ptr++;
492                 while (isspace(*ptr)) ptr++;
493                 
494                 if ( bdb->bi_flags & BDB_IS_OPEN ) {
495                         bdb->bi_flags |= BDB_UPD_CONFIG;
496                         c->cleanup = bdb_cf_cleanup;
497                 } else {
498                 /* If we're just starting up...
499                  */
500                         FILE *f;
501                         /* If a DB_CONFIG file exists, or we don't know the path
502                          * to the DB_CONFIG file, ignore these directives
503                          */
504                         if (( bdb->bi_flags & BDB_HAS_CONFIG ) || !bdb->bi_db_config_path )
505                                 break;
506                         f = fopen( bdb->bi_db_config_path, "a" );
507                         if ( f ) {
508                                 /* FIXME: EBCDIC probably needs special handling */
509                                 fprintf( f, "%s\n", ptr );
510                                 fclose( f );
511                         }
512                 }
513                 ber_str2bv( ptr, 0, 1, &bv );
514                 ber_bvarray_add( &bdb->bi_db_config, &bv );
515                 }
516                 break;
517
518         case BDB_DIRECTORY: {
519                 FILE *f;
520                 char *ptr;
521
522                 if ( bdb->bi_dbenv_home )
523                         ch_free( bdb->bi_dbenv_home );
524                 bdb->bi_dbenv_home = c->value_string;
525
526                 /* See if a DB_CONFIG file already exists here */
527                 if ( bdb->bi_db_config_path )
528                         ch_free( bdb->bi_db_config_path );
529                 bdb->bi_db_config_path = ch_malloc( strlen( bdb->bi_dbenv_home ) +
530                         STRLENOF(LDAP_DIRSEP) + STRLENOF("DB_CONFIG") + 1 );
531                 ptr = lutil_strcopy( bdb->bi_db_config_path, bdb->bi_dbenv_home );
532                 *ptr++ = LDAP_DIRSEP[0];
533                 strcpy( ptr, "DB_CONFIG" );
534
535                 f = fopen( bdb->bi_db_config_path, "r" );
536                 if ( f ) {
537                         bdb->bi_flags |= BDB_HAS_CONFIG;
538                         fclose(f);
539                 }
540                 }
541                 break;
542
543         case BDB_NOSYNC:
544                 if ( c->value_int )
545                         bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC;
546                 else
547                         bdb->bi_dbenv_xflags &= ~DB_TXN_NOSYNC;
548                 if ( bdb->bi_flags & BDB_IS_OPEN ) {
549                         bdb->bi_dbenv->set_flags( bdb->bi_dbenv, DB_TXN_NOSYNC,
550                                 c->value_int );
551                 }
552                 break;
553
554         case BDB_INDEX:
555                 rc = bdb_attr_index_config( bdb, c->fname, c->lineno,
556                         c->argc - 1, &c->argv[1] );
557
558                 if( rc != LDAP_SUCCESS ) return 1;
559                 if (( bdb->bi_flags & BDB_IS_OPEN ) && !bdb->bi_index_task ) {
560                         /* Start the task as soon as we finish here */
561                         bdb->bi_index_task = ldap_pvt_runqueue_insert( &slapd_rq, 60,
562                                 bdb_online_index, c->be,
563                                 LDAP_XSTRING(bdb_online_index), c->be->be_suffix[0].bv_val );
564                 }
565                 break;
566
567         case BDB_LOCKD:
568                 rc = verb_to_mask( c->argv[1], bdb_lockd );
569                 if ( BER_BVISNULL(&bdb_lockd[rc].word) ) {
570                         fprintf( stderr, "%s: "
571                                 "bad policy (%s) in \"lockDetect <policy>\" line\n",
572                                 c->log, c->argv[1] );
573                         return 1;
574                 }
575                 bdb->bi_lock_detect = rc;
576                 break;
577
578         case BDB_SSTACK:
579                 if ( c->value_int < MINIMUM_SEARCH_STACK_DEPTH ) {
580                         fprintf( stderr,
581                 "%s: depth %d too small, using %d\n",
582                         c->log, c->value_int, MINIMUM_SEARCH_STACK_DEPTH );
583                         c->value_int = MINIMUM_SEARCH_STACK_DEPTH;
584                 }
585                 bdb->bi_search_stack_depth = c->value_int;
586                 break;
587         }
588         return 0;
589 }
590
591 int bdb_back_init_cf( BackendInfo *bi )
592 {
593         int rc;
594         bi->bi_cf_table = bdbcfg;
595
596         rc = config_register_schema( bdbcfg, bdbocs );
597         if ( rc ) return rc;
598         bdbcfg[0].ad = slap_schema.si_ad_objectClass;
599         return 0;
600 }