1 /* init.c - initialize bdb backend */
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>
21 #include <ac/unistd.h>
22 #include <ac/stdlib.h>
30 static const struct bdbi_database {
35 } bdbi_databases[] = {
36 { "id2entry" BDB_SUFFIX, "id2entry", DB_BTREE, 0 },
37 { "dn2id" BDB_SUFFIX, "dn2id", DB_BTREE, 0 },
41 typedef void * db_malloc(size_t);
42 typedef void * db_realloc(void *, size_t);
45 bdb_db_init( BackendDB *be )
49 Debug( LDAP_DEBUG_TRACE,
50 LDAP_XSTRING(bdb_db_init) ": Initializing " BDB_UCTYPE " database\n",
53 /* allocate backend-database-specific stuff */
54 bdb = (struct bdb_info *) ch_calloc( 1, sizeof(struct bdb_info) );
56 /* DBEnv parameters */
57 bdb->bi_dbenv_home = ch_strdup( SLAPD_DEFAULT_DB_DIR );
58 bdb->bi_dbenv_xflags = 0;
59 bdb->bi_dbenv_mode = SLAPD_DEFAULT_DB_MODE;
61 bdb->bi_cache.c_maxsize = DEFAULT_CACHE_SIZE;
63 bdb->bi_lock_detect = DB_LOCK_DEFAULT;
64 bdb->bi_search_stack_depth = DEFAULT_SEARCH_STACK_DEPTH;
65 bdb->bi_search_stack = NULL;
67 ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex );
68 ldap_pvt_thread_mutex_init( &bdb->bi_lastid_mutex );
69 ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex );
70 ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_dntree.bei_kids_mutex );
71 ldap_pvt_thread_rdwr_init ( &bdb->bi_cache.c_rwlock );
72 ldap_pvt_thread_rdwr_init( &bdb->bi_idl_tree_rwlock );
73 ldap_pvt_thread_mutex_init( &bdb->bi_idl_tree_lrulock );
76 be->be_cf_ocs = be->bd_info->bi_cf_ocs;
82 * Unconditionally perform a database recovery. Only works on
83 * databases that were previously opened with transactions and
87 bdb_do_recovery( BackendDB *be )
89 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
93 char path[MAXPATHLEN], *ptr;
95 /* Create and init the recovery environment */
96 rc = db_env_create( &re_dbenv, 0 );
98 Debug( LDAP_DEBUG_ANY,
99 "bdb_do_recovery: db_env_create failed: %s (%d)\n",
100 db_strerror(rc), rc, 0 );
103 re_dbenv->set_errpfx( re_dbenv, be->be_suffix[0].bv_val );
104 re_dbenv->set_errcall( re_dbenv, bdb_errcall );
105 (void)re_dbenv->set_verbose(re_dbenv, DB_VERB_RECOVERY, 1);
106 #if DB_VERSION_FULL < 0x04030000
107 (void)re_dbenv->set_verbose(re_dbenv, DB_VERB_CHKPOINT, 1);
109 re_dbenv->set_msgcall( re_dbenv, bdb_msgcall );
112 flags = DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL |
113 DB_INIT_TXN | DB_USE_ENVIRON | DB_RECOVER;
115 /* If a key was set, use shared memory for the BDB environment */
116 if ( bdb->bi_shm_key ) {
117 re_dbenv->set_shm_key( re_dbenv, bdb->bi_shm_key );
118 flags |= DB_SYSTEM_MEM;
121 /* Open the environment, which will also perform the recovery */
123 strcpy( path, bdb->bi_dbenv_home );
125 rc = re_dbenv->open( re_dbenv,
128 bdb->bi_dbenv_mode );
130 rc = re_dbenv->open( re_dbenv,
133 bdb->bi_dbenv_mode );
136 Debug( LDAP_DEBUG_ANY,
137 "bdb_do_recovery: dbenv_open failed: %s (%d)\n",
138 db_strerror(rc), rc, 0 );
141 (void) re_dbenv->close( re_dbenv, 0 );
143 /* By convention we reset the mtime for id2entry.bdb to the current time */
144 ptr = lutil_strcopy( path, bdb->bi_dbenv_home);
145 *ptr++ = LDAP_DIRSEP[0];
146 strcpy( ptr, bdbi_databases[0].file);
147 (void) utime( path, NULL);
153 * Database recovery logic:
154 * This function is called whenever the database appears to have been
155 * shut down uncleanly, as determined by the alock functions.
156 * Because of the -q function in slapadd, there is also the possibility
157 * that the shutdown happened when transactions weren't being used and
158 * the database is likely to be corrupt. The function checks for this
159 * condition by examining the environment to make sure it had previously
160 * been opened with transactions enabled. If this is the case, the
161 * database is recovered as usual. If transactions were not enabled,
162 * then this function will return a fail.
165 bdb_db_recover( BackendDB *be )
167 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
172 char path[MAXPATHLEN];
175 /* Create the recovery environment, then open it.
176 * We use the DB_JOIN in combination with a flags value of
177 * zero so we join an existing environment and can read the
178 * value of the flags that were used the last time the
179 * environment was opened. DB_CREATE is added because the
180 * open would fail if the only thing that had been done
181 * was an open with transactions and logs disabled.
183 rc = db_env_create( &re_dbenv, 0 );
185 Debug( LDAP_DEBUG_ANY,
186 "bdb_db_recover: db_env_create failed: %s (%d)\n",
187 db_strerror(rc), rc, 0 );
190 re_dbenv->set_errpfx( re_dbenv, be->be_suffix[0].bv_val );
191 re_dbenv->set_errcall( re_dbenv, bdb_errcall );
193 Debug( LDAP_DEBUG_TRACE,
194 "bdb_db_recover: dbenv_open(%s)\n",
195 bdb->bi_dbenv_home, 0, 0);
198 strcpy( path, bdb->bi_dbenv_home );
200 rc = re_dbenv->open( re_dbenv,
203 bdb->bi_dbenv_mode );
205 rc = re_dbenv->open( re_dbenv,
208 bdb->bi_dbenv_mode );
212 Debug( LDAP_DEBUG_TRACE,
213 "bdb_db_recover: DB environment files are missing, assuming it was "
214 "manually recovered\n", 0, 0, 0 );
218 Debug( LDAP_DEBUG_ANY,
219 "bdb_db_recover: dbenv_open failed: %s (%d)\n",
220 db_strerror(rc), rc, 0 );
225 * Check the flags that had been used in the previous open.
226 * The environment needed to have had both
227 * DB_INIT_LOG and DB_INIT_TXN set for us to be willing to
228 * recover the database. Otherwise the an app failed while running
229 * without transactions and logs enabled and the dn2id and id2entry
230 * mapping is likely to be corrupt.
232 rc = re_dbenv->get_open_flags( re_dbenv, &flags );
234 Debug( LDAP_DEBUG_ANY,
235 "bdb_db_recover: get_open_flags failed: %s (%d)\n",
236 db_strerror(rc), rc, 0 );
240 (void) re_dbenv->close( re_dbenv, 0 );
242 if( (flags & DB_INIT_LOG) && (flags & DB_INIT_TXN) ) {
243 return bdb_do_recovery( be );
247 Debug( LDAP_DEBUG_ANY,
248 "bdb_db_recover: Database cannot be recovered. "\
249 "Restore from backup!\n", 0, 0, 0);
256 bdb_db_open( BackendDB *be )
259 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
260 struct stat stat1, stat2;
262 char path[MAXPATHLEN];
265 Debug( LDAP_DEBUG_ARGS,
267 be->be_suffix[0].bv_val, 0, 0 );
269 #ifndef BDB_MULTIPLE_SUFFIXES
270 if ( be->be_suffix[1].bv_val ) {
271 Debug( LDAP_DEBUG_ANY,
272 "bdb_db_open: only one suffix allowed\n", 0, 0, 0 );
277 /* Check existence of dbenv_home. Any error means trouble */
278 rc = stat( bdb->bi_dbenv_home, &stat1 );
280 Debug( LDAP_DEBUG_ANY,
281 "bdb_db_open: Cannot access database directory %s (%d)\n",
282 bdb->bi_dbenv_home, errno, 0 );
286 /* Perform database use arbitration/recovery logic */
287 rc = alock_open( &bdb->bi_alock_info,
290 slapMode & SLAP_TOOL_READONLY ?
291 ALOCK_LOCKED : ALOCK_UNIQUE );
293 if( rc == ALOCK_RECOVER ) {
294 Debug( LDAP_DEBUG_ANY,
295 "bdb_db_open: unclean shutdown detected;"
296 " attempting recovery.\n",
298 if( bdb_db_recover( be ) != 0 ) {
299 Debug( LDAP_DEBUG_ANY,
300 "bdb_db_open: DB recovery failed.\n",
304 if( alock_recover (&bdb->bi_alock_info) != 0 ) {
305 Debug( LDAP_DEBUG_ANY,
306 "bdb_db_open: alock_recover failed\n",
311 } else if( rc == ALOCK_BUSY ) {
312 Debug( LDAP_DEBUG_ANY,
313 "bdb_db_open: database already in use\n",
316 } else if( rc != ALOCK_CLEAN ) {
317 Debug( LDAP_DEBUG_ANY,
318 "bdb_db_open: alock package is unstable\n",
324 * The DB_CONFIG file may have changed. If so, recover the
325 * database so that new settings are put into effect. Also
326 * note the possible absence of DB_CONFIG in the log.
328 if( stat( bdb->bi_db_config_path, &stat1 ) == 0 ) {
329 ptr = lutil_strcopy(path, bdb->bi_dbenv_home);
330 *ptr++ = LDAP_DIRSEP[0];
331 strcpy( ptr, bdbi_databases[0].file);
332 if( stat( path, &stat2 ) == 0 ) {
333 if( stat2.st_mtime <= stat1.st_mtime ) {
334 Debug( LDAP_DEBUG_ANY,
335 "bdb_db_open: DB_CONFIG for suffix %s has changed.\n"
336 "Performing database recovery to activate new settings.\n",
337 be->be_suffix[0].bv_val, 0, 0 );
338 if( bdb_do_recovery( be ) != 0) {
339 Debug( LDAP_DEBUG_ANY,
340 "bdb_db_open: db recovery failed.\n",
349 Debug( LDAP_DEBUG_ANY,
350 "bdb_db_open: Warning - No DB_CONFIG file found "
351 "in directory %s: (%d)\n"
352 "Expect poor performance for suffix %s.\n",
353 bdb->bi_dbenv_home, errno, be->be_suffix[0].bv_val );
356 flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE;
357 if ( !( slapMode & SLAP_TOOL_QUICK ))
358 flags |= DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN;
360 rc = db_env_create( &bdb->bi_dbenv, 0 );
362 Debug( LDAP_DEBUG_ANY,
363 "bdb_db_open: db_env_create failed: %s (%d)\n",
364 db_strerror(rc), rc, 0 );
368 /* If a key was set, use shared memory for the BDB environment */
369 if ( bdb->bi_shm_key ) {
370 bdb->bi_dbenv->set_shm_key( bdb->bi_dbenv, bdb->bi_shm_key );
371 flags |= DB_SYSTEM_MEM;
374 bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val );
375 bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
376 bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect );
378 /* One long-lived TXN per thread, two TXNs per write op */
379 bdb->bi_dbenv->set_tx_max( bdb->bi_dbenv, connection_pool_max * 3 );
381 #ifdef SLAP_ZONE_ALLOC
382 if ( bdb->bi_cache.c_maxsize ) {
383 bdb->bi_cache.c_zctx = slap_zn_mem_create(
391 if ( bdb->bi_idl_cache_max_size ) {
392 bdb->bi_idl_tree = NULL;
393 bdb->bi_idl_cache_size = 0;
396 if( bdb->bi_dbenv_xflags != 0 ) {
397 rc = bdb->bi_dbenv->set_flags( bdb->bi_dbenv,
398 bdb->bi_dbenv_xflags, 1);
400 Debug( LDAP_DEBUG_ANY,
401 "bdb_db_open: dbenv_set_flags failed: %s (%d)\n",
402 db_strerror(rc), rc, 0 );
407 Debug( LDAP_DEBUG_TRACE,
408 "bdb_db_open: dbenv_open(%s)\n",
409 bdb->bi_dbenv_home, 0, 0);
412 strcpy( path, bdb->bi_dbenv_home );
414 rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
417 bdb->bi_dbenv_mode );
419 rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
422 bdb->bi_dbenv_mode );
425 Debug( LDAP_DEBUG_ANY,
426 "bdb_db_open: dbenv_open failed: %s (%d)\n",
427 db_strerror(rc), rc, 0 );
431 flags = DB_THREAD | bdb->bi_db_opflags;
433 #ifdef DB_AUTO_COMMIT
434 if ( !( slapMode & SLAP_TOOL_QUICK ))
435 flags |= DB_AUTO_COMMIT;
438 bdb->bi_databases = (struct bdb_db_info **) ch_malloc(
439 BDB_INDICES * sizeof(struct bdb_db_info *) );
441 /* open (and create) main database */
442 for( i = 0; bdbi_databases[i].name; i++ ) {
443 struct bdb_db_info *db;
445 db = (struct bdb_db_info *) ch_calloc(1, sizeof(struct bdb_db_info));
447 rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 );
449 Debug( LDAP_DEBUG_ANY,
450 "bdb_db_open: db_create(%s) failed: %s (%d)\n",
451 bdb->bi_dbenv_home, db_strerror(rc), rc );
455 if( i == BDB_ID2ENTRY ) {
456 rc = db->bdi_db->set_pagesize( db->bdi_db,
457 BDB_ID2ENTRY_PAGESIZE );
458 if ( slapMode & SLAP_TOOL_READMAIN ) {
464 rc = db->bdi_db->set_flags( db->bdi_db,
465 DB_DUP | DB_DUPSORT );
467 if ( slapMode & SLAP_TOOL_READONLY ) {
473 if ( slapMode & (SLAP_TOOL_READONLY|SLAP_TOOL_READMAIN) ) {
479 rc = db->bdi_db->set_pagesize( db->bdi_db,
484 strcpy( path, bdbi_databases[i].file );
486 rc = DB_OPEN( db->bdi_db,
488 /* bdbi_databases[i].name, */ NULL,
489 bdbi_databases[i].type,
490 bdbi_databases[i].flags | flags,
491 bdb->bi_dbenv_mode );
493 rc = DB_OPEN( db->bdi_db,
494 bdbi_databases[i].file,
495 /* bdbi_databases[i].name, */ NULL,
496 bdbi_databases[i].type,
497 bdbi_databases[i].flags | flags,
498 bdb->bi_dbenv_mode );
502 char buf[SLAP_TEXT_BUFLEN];
504 snprintf( buf, sizeof(buf), "%s/%s",
505 bdb->bi_dbenv_home, bdbi_databases[i].file );
506 Debug( LDAP_DEBUG_ANY,
507 "bdb_db_open: db_open(%s) failed: %s (%d)\n",
508 buf, db_strerror(rc), rc );
512 flags &= ~(DB_CREATE | DB_RDONLY);
513 db->bdi_name = bdbi_databases[i].name;
514 bdb->bi_databases[i] = db;
517 bdb->bi_databases[i] = NULL;
518 bdb->bi_ndatabases = i;
521 rc = bdb_last_id( be, NULL );
523 Debug( LDAP_DEBUG_ANY,
524 "bdb_db_open: last_id(%s) failed: %s (%d)\n",
525 bdb->bi_dbenv_home, db_strerror(rc), rc );
529 if ( !( slapMode & SLAP_TOOL_QUICK )) {
530 XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker);
533 bdb->bi_flags |= BDB_IS_OPEN;
539 bdb_db_close( BackendDB *be )
542 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
543 struct bdb_db_info *db;
544 bdb_idl_cache_entry_t *entry, *next_entry;
546 bdb->bi_flags &= ~BDB_IS_OPEN;
548 ber_bvarray_free( bdb->bi_db_config );
549 bdb->bi_db_config = NULL;
551 while( bdb->bi_databases && bdb->bi_ndatabases-- ) {
552 db = bdb->bi_databases[bdb->bi_ndatabases];
553 rc = db->bdi_db->close( db->bdi_db, 0 );
554 /* Lower numbered names are not strdup'd */
555 if( bdb->bi_ndatabases >= BDB_NDB )
556 free( db->bdi_name );
559 free( bdb->bi_databases );
560 bdb->bi_databases = NULL;
562 bdb_cache_release_all (&bdb->bi_cache);
564 if ( bdb->bi_idl_cache_max_size ) {
565 ldap_pvt_thread_rdwr_wlock ( &bdb->bi_idl_tree_rwlock );
566 avl_free( bdb->bi_idl_tree, NULL );
567 bdb->bi_idl_tree = NULL;
568 entry = bdb->bi_idl_lru_head;
569 while ( entry != NULL ) {
570 next_entry = entry->idl_lru_next;
573 free( entry->kstr.bv_val );
577 bdb->bi_idl_lru_head = bdb->bi_idl_lru_tail = NULL;
578 ldap_pvt_thread_rdwr_wunlock ( &bdb->bi_idl_tree_rwlock );
581 if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_dbenv ) {
582 XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
583 bdb->bi_cache.c_locker = 0;
586 /* close db environment */
587 if( bdb->bi_dbenv ) {
588 /* force a checkpoint, but not if we were ReadOnly,
589 * and not in Quick mode since there are no transactions there.
591 if ( !( slapMode & ( SLAP_TOOL_QUICK|SLAP_TOOL_READONLY ))) {
592 rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
594 Debug( LDAP_DEBUG_ANY,
595 "bdb_db_close: txn_checkpoint failed: %s (%d)\n",
596 db_strerror(rc), rc, 0 );
600 rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
601 bdb->bi_dbenv = NULL;
603 Debug( LDAP_DEBUG_ANY,
604 "bdb_db_close: close failed: %s (%d)\n",
605 db_strerror(rc), rc, 0 );
609 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 2
610 /* Delete the environment if we were in quick mode. This
611 * works around a bug in bdb4.2 that interferes with the
612 * operation of db_stat and other tools after a slapadd -q
613 * or slapindex -q has taken place.
615 if( slapMode & SLAP_TOOL_QUICK ) {
616 rc = db_env_create( &bdb->bi_dbenv, 0 );
618 Debug( LDAP_DEBUG_ANY,
619 "bdb_db_close: db_env_create failed: %s (%d)\n",
620 db_strerror(rc), rc, 0 );
623 rc = bdb->bi_dbenv->remove(bdb->bi_dbenv, bdb->bi_dbenv_home,
625 bdb->bi_dbenv = NULL;
627 Debug( LDAP_DEBUG_ANY,
628 "bdb_db_close: dbenv_remove failed: %s (%d)\n",
629 db_strerror(rc), rc, 0 );
636 rc = alock_close( &bdb->bi_alock_info );
638 Debug( LDAP_DEBUG_ANY,
639 "bdb_db_close: alock_close failed\n", 0, 0, 0 );
647 bdb_db_destroy( BackendDB *be )
650 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
652 if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home );
653 if( bdb->bi_db_config_path ) ch_free( bdb->bi_db_config_path );
655 bdb_attr_index_destroy( bdb->bi_attrs );
657 ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock );
658 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex );
659 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_dntree.bei_kids_mutex );
660 ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
661 ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
662 ldap_pvt_thread_rdwr_destroy( &bdb->bi_idl_tree_rwlock );
663 ldap_pvt_thread_mutex_destroy( &bdb->bi_idl_tree_lrulock );
666 be->be_private = NULL;
677 static char *controls[] = {
679 LDAP_CONTROL_MANAGEDSAIT,
681 LDAP_CONTROL_PAGEDRESULTS,
682 #ifdef LDAP_CONTROL_SUBENTRIES
683 LDAP_CONTROL_SUBENTRIES,
685 #ifdef LDAP_CONTROL_X_PERMISSIVE_MODIFY
686 LDAP_CONTROL_X_PERMISSIVE_MODIFY,
691 /* initialize the underlying database system */
692 Debug( LDAP_DEBUG_TRACE,
693 LDAP_XSTRING(bdb_back_initialize) ": initialize "
694 BDB_UCTYPE " backend\n", 0, 0, 0 );
697 SLAP_BFLAG_INCREMENT |
698 #ifdef BDB_SUBENTRIES
699 SLAP_BFLAG_SUBENTRIES |
702 SLAP_BFLAG_REFERRALS;
704 bi->bi_controls = controls;
706 { /* version check */
707 int major, minor, patch, ver;
708 char *version = db_version( &major, &minor, &patch );
712 /* All our stdio does an ASCII to EBCDIC conversion on
713 * the output. Strings from the BDB library are already
714 * in EBCDIC; we have to go back and forth...
716 strcpy( v2, version );
721 ver = (major << 24) | (minor << 16) | patch;
722 if( ver != DB_VERSION_FULL ) {
723 /* fail if a versions don't match */
724 Debug( LDAP_DEBUG_ANY,
725 LDAP_XSTRING(bdb_back_initialize) ": "
726 "BDB library version mismatch:"
727 " expected " DB_VERSION_STRING ","
728 " got %s\n", version, 0, 0 );
732 Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_back_initialize)
733 ": %s\n", version, 0, 0 );
736 db_env_set_func_free( ber_memfree );
737 db_env_set_func_malloc( (db_malloc *)ber_memalloc );
738 db_env_set_func_realloc( (db_realloc *)ber_memrealloc );
740 /* This is a no-op on a NO_THREAD build. Leave the default
741 * alone so that BDB will sleep on interprocess conflicts.
743 db_env_set_func_yield( ldap_pvt_thread_yield );
751 bi->bi_db_init = bdb_db_init;
752 bi->bi_db_config = config_generic_wrapper;
753 bi->bi_db_open = bdb_db_open;
754 bi->bi_db_close = bdb_db_close;
755 bi->bi_db_destroy = bdb_db_destroy;
757 bi->bi_op_add = bdb_add;
758 bi->bi_op_bind = bdb_bind;
759 bi->bi_op_compare = bdb_compare;
760 bi->bi_op_delete = bdb_delete;
761 bi->bi_op_modify = bdb_modify;
762 bi->bi_op_modrdn = bdb_modrdn;
763 bi->bi_op_search = bdb_search;
765 bi->bi_op_unbind = 0;
767 bi->bi_extended = bdb_extended;
769 bi->bi_chk_referrals = bdb_referrals;
770 bi->bi_operational = bdb_operational;
771 bi->bi_has_subordinates = bdb_hasSubordinates;
772 bi->bi_entry_release_rw = bdb_entry_release;
773 bi->bi_entry_get_rw = bdb_entry_get;
776 * hooks for slap tools
778 bi->bi_tool_entry_open = bdb_tool_entry_open;
779 bi->bi_tool_entry_close = bdb_tool_entry_close;
780 bi->bi_tool_entry_first = bdb_tool_entry_next;
781 bi->bi_tool_entry_next = bdb_tool_entry_next;
782 bi->bi_tool_entry_get = bdb_tool_entry_get;
783 bi->bi_tool_entry_put = bdb_tool_entry_put;
784 bi->bi_tool_entry_reindex = bdb_tool_entry_reindex;
785 bi->bi_tool_sync = 0;
786 bi->bi_tool_dn2id_get = bdb_tool_dn2id_get;
787 bi->bi_tool_id2entry_get = bdb_tool_id2entry_get;
788 bi->bi_tool_entry_modify = bdb_tool_entry_modify;
790 bi->bi_connection_init = 0;
791 bi->bi_connection_destroy = 0;
793 rc = bdb_back_init_cf( bi );
798 #if (SLAPD_BDB == SLAPD_MOD_DYNAMIC && !defined(BDB_HIER)) || \
799 (SLAPD_HDB == SLAPD_MOD_DYNAMIC && defined(BDB_HIER))
801 /* conditionally define the init_module() function */
803 SLAP_BACKEND_INIT_MODULE( hdb )
804 #else /* !BDB_HIER */
805 SLAP_BACKEND_INIT_MODULE( bdb )
806 #endif /* !BDB_HIER */
808 #endif /* SLAPD_[BH]DB == SLAPD_MOD_DYNAMIC */