]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/init.c
e9ef03be63cc2de7b123b569a00559cddb3899b0
[openldap] / servers / slapd / back-bdb / init.c
1 /* init.c - initialize bdb backend */
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 #include <ac/unistd.h>
22 #include <ac/stdlib.h>
23
24 #include "back-bdb.h"
25 #include <lutil.h>
26 #include <ldap_rq.h>
27 #include "alock.h"
28
29 static const struct bdbi_database {
30         char *file;
31         char *name;
32         int type;
33         int flags;
34 } bdbi_databases[] = {
35         { "id2entry" BDB_SUFFIX, "id2entry", DB_BTREE, 0 },
36         { "dn2id" BDB_SUFFIX, "dn2id", DB_BTREE, 0 },
37         { NULL, NULL, 0, 0 }
38 };
39
40 typedef void * db_malloc(size_t);
41 typedef void * db_realloc(void *, size_t);
42
43 static int
44 bdb_db_init( BackendDB *be )
45 {
46         struct bdb_info *bdb;
47
48         Debug( LDAP_DEBUG_TRACE,
49                 LDAP_XSTRING(bdb_db_init) ": Initializing " BDB_UCTYPE " database\n",
50                 0, 0, 0 );
51
52         /* allocate backend-database-specific stuff */
53         bdb = (struct bdb_info *) ch_calloc( 1, sizeof(struct bdb_info) );
54
55         /* DBEnv parameters */
56         bdb->bi_dbenv_home = ch_strdup( SLAPD_DEFAULT_DB_DIR );
57         bdb->bi_dbenv_xflags = 0;
58         bdb->bi_dbenv_mode = SLAPD_DEFAULT_DB_MODE;
59
60         bdb->bi_cache.c_maxsize = DEFAULT_CACHE_SIZE;
61
62         bdb->bi_lock_detect = DB_LOCK_DEFAULT;
63         bdb->bi_search_stack_depth = DEFAULT_SEARCH_STACK_DEPTH;
64         bdb->bi_search_stack = NULL;
65
66         ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex );
67         ldap_pvt_thread_mutex_init( &bdb->bi_lastid_mutex );
68         ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex );
69         ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_dntree.bei_kids_mutex );
70         ldap_pvt_thread_rdwr_init ( &bdb->bi_cache.c_rwlock );
71
72         be->be_private = bdb;
73         be->be_cf_table = be->bd_info->bi_cf_table;
74
75         return 0;
76 }
77
78 static void *
79 bdb_checkpoint( void *ctx, void *arg )
80 {
81         struct re_s *rtask = arg;
82         struct bdb_info *bdb = rtask->arg;
83         
84         TXN_CHECKPOINT( bdb->bi_dbenv, bdb->bi_txn_cp_kbyte,
85                 bdb->bi_txn_cp_min, 0 );
86         ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
87         ldap_pvt_runqueue_stoptask( &slapd_rq, rtask );
88         ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
89         return NULL;
90 }
91
92 static int
93 bdb_db_open( BackendDB *be )
94 {
95         int rc, i;
96         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
97         u_int32_t flags;
98 #ifdef HAVE_EBCDIC
99         char path[MAXPATHLEN];
100 #endif
101
102         Debug( LDAP_DEBUG_ARGS,
103                 "bdb_db_open: %s\n",
104                 be->be_suffix[0].bv_val, 0, 0 );
105
106 #ifndef BDB_MULTIPLE_SUFFIXES
107         if ( be->be_suffix[1].bv_val ) {
108         Debug( LDAP_DEBUG_ANY,
109                 "bdb_db_open: only one suffix allowed\n", 0, 0, 0 );
110                 return -1;
111         }
112 #endif
113         /* we should check existance of dbenv_home and db_directory */
114
115         rc = db_env_create( &bdb->bi_dbenv, 0 );
116         if( rc != 0 ) {
117                 Debug( LDAP_DEBUG_ANY,
118                         "bdb_db_open: db_env_create failed: %s (%d)\n",
119                         db_strerror(rc), rc, 0 );
120                 return rc;
121         }
122
123         flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE;
124
125         if ( !( slapMode & SLAP_TOOL_QUICK ))
126                 flags |= DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN;
127         
128         rc = alock_open( &bdb->bi_alock_info, "slapd", bdb->bi_dbenv_home,
129                 slapMode & SLAP_TOOL_READONLY ?  ALOCK_LOCKED : ALOCK_UNIQUE );
130         if( rc == ALOCK_RECOVER ) {
131                 Debug( LDAP_DEBUG_ANY,
132                         "bdb_db_open: alock_open: recovery required\n", 0, 0, 0 );
133                 flags |= DB_RECOVER;
134         } else if( rc == ALOCK_BUSY ) {
135                 Debug( LDAP_DEBUG_ANY,
136                    "bdb_db_open: alock_open: database in use\n", 0, 0, 0 );
137                 return -1;
138         } else if( rc != ALOCK_CLEAN ) {
139                 Debug( LDAP_DEBUG_ANY,
140                    "bdb_db_open: alock_open: database unstable\n", 0, 0, 0 );
141                 return -1;
142         }
143
144         /* If a key was set, use shared memory for the BDB environment */
145         if ( bdb->bi_shm_key ) {
146                 bdb->bi_dbenv->set_shm_key( bdb->bi_dbenv, bdb->bi_shm_key );
147                 flags |= DB_SYSTEM_MEM;
148         }
149
150         bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val );
151         bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
152         bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect );
153
154         /* One long-lived TXN per thread, two TXNs per write op */
155         bdb->bi_dbenv->set_tx_max( bdb->bi_dbenv, connection_pool_max * 3 );
156
157 #ifdef SLAP_ZONE_ALLOC
158         if ( bdb->bi_cache.c_maxsize ) {
159                 bdb->bi_cache.c_zctx = slap_zn_mem_create(
160                                                                 SLAP_ZONE_INITSIZE,
161                                                                 SLAP_ZONE_MAXSIZE,
162                                                                 SLAP_ZONE_DELTA,
163                                                                 SLAP_ZONE_SIZE);
164         }
165 #endif
166
167         if ( bdb->bi_idl_cache_max_size ) {
168                 bdb->bi_idl_tree = NULL;
169                 ldap_pvt_thread_rdwr_init( &bdb->bi_idl_tree_rwlock );
170                 ldap_pvt_thread_mutex_init( &bdb->bi_idl_tree_lrulock );
171                 bdb->bi_idl_cache_size = 0;
172         }
173
174         if( bdb->bi_dbenv_xflags != 0 ) {
175                 rc = bdb->bi_dbenv->set_flags( bdb->bi_dbenv,
176                         bdb->bi_dbenv_xflags, 1);
177                 if( rc != 0 ) {
178                         Debug( LDAP_DEBUG_ANY,
179                                 "bdb_db_open: dbenv_set_flags failed: %s (%d)\n",
180                                 db_strerror(rc), rc, 0 );
181                         return rc;
182                 }
183         }
184
185         Debug( LDAP_DEBUG_TRACE,
186                 "bdb_db_open: dbenv_open(%s)\n",
187                 bdb->bi_dbenv_home, 0, 0);
188
189 #ifdef HAVE_EBCDIC
190         strcpy( path, bdb->bi_dbenv_home );
191         __atoe( path );
192         rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
193                 path,
194                 flags,
195                 bdb->bi_dbenv_mode );
196 #else
197         rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
198                 bdb->bi_dbenv_home,
199                 flags,
200                 bdb->bi_dbenv_mode );
201 #endif
202         if( rc != 0 ) {
203                 Debug( LDAP_DEBUG_ANY,
204                         "bdb_db_open: dbenv_open failed: %s (%d)\n",
205                         db_strerror(rc), rc, 0 );
206                 return rc;
207         }
208         if( flags & DB_RECOVER ) {
209                 rc = alock_recover (&bdb->bi_alock_info);
210                 if( rc != 0 ) {
211                         Debug( LDAP_DEBUG_ANY,
212                            "bdb_db_open: unable to alock_recover\n", 0, 0, 0 );
213                         return -1;
214                 }
215         }
216
217         flags = DB_THREAD | bdb->bi_db_opflags;
218
219 #ifdef DB_AUTO_COMMIT
220         if ( !( slapMode & SLAP_TOOL_QUICK ))
221                 flags |= DB_AUTO_COMMIT;
222 #endif
223
224         bdb->bi_databases = (struct bdb_db_info **) ch_malloc(
225                 BDB_INDICES * sizeof(struct bdb_db_info *) );
226
227         /* open (and create) main database */
228         for( i = 0; bdbi_databases[i].name; i++ ) {
229                 struct bdb_db_info *db;
230
231                 db = (struct bdb_db_info *) ch_calloc(1, sizeof(struct bdb_db_info));
232
233                 rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 );
234                 if( rc != 0 ) {
235                         Debug( LDAP_DEBUG_ANY,
236                                 "bdb_db_open: db_create(%s) failed: %s (%d)\n",
237                                 bdb->bi_dbenv_home, db_strerror(rc), rc );
238                         return rc;
239                 }
240
241                 if( i == BDB_ID2ENTRY ) {
242                         rc = db->bdi_db->set_pagesize( db->bdi_db,
243                                 BDB_ID2ENTRY_PAGESIZE );
244                         if ( slapMode & SLAP_TOOL_READMAIN ) {
245                                 flags |= DB_RDONLY;
246                         } else {
247                                 flags |= DB_CREATE;
248                         }
249                 } else {
250                         rc = db->bdi_db->set_flags( db->bdi_db, 
251                                 DB_DUP | DB_DUPSORT );
252 #ifndef BDB_HIER
253                         if ( slapMode & SLAP_TOOL_READONLY ) {
254                                 flags |= DB_RDONLY;
255                         } else {
256                                 flags |= DB_CREATE;
257                         }
258 #else
259                         if ( slapMode & (SLAP_TOOL_READONLY|SLAP_TOOL_READMAIN) ) {
260                                 flags |= DB_RDONLY;
261                         } else {
262                                 flags |= DB_CREATE;
263                         }
264 #endif
265                         rc = db->bdi_db->set_pagesize( db->bdi_db,
266                                 BDB_PAGESIZE );
267                 }
268
269 #ifdef HAVE_EBCDIC
270                 strcpy( path, bdbi_databases[i].file );
271                 __atoe( path );
272                 rc = DB_OPEN( db->bdi_db,
273                         path,
274                 /*      bdbi_databases[i].name, */ NULL,
275                         bdbi_databases[i].type,
276                         bdbi_databases[i].flags | flags,
277                         bdb->bi_dbenv_mode );
278 #else
279                 rc = DB_OPEN( db->bdi_db,
280                         bdbi_databases[i].file,
281                 /*      bdbi_databases[i].name, */ NULL,
282                         bdbi_databases[i].type,
283                         bdbi_databases[i].flags | flags,
284                         bdb->bi_dbenv_mode );
285 #endif
286
287                 if ( rc != 0 ) {
288                         char    buf[SLAP_TEXT_BUFLEN];
289
290                         snprintf( buf, sizeof(buf), "%s/%s", 
291                                 bdb->bi_dbenv_home, bdbi_databases[i].file );
292                         Debug( LDAP_DEBUG_ANY,
293                                 "bdb_db_open: db_open(%s) failed: %s (%d)\n",
294                                 buf, db_strerror(rc), rc );
295                         return rc;
296                 }
297
298                 flags &= ~(DB_CREATE | DB_RDONLY);
299                 db->bdi_name = bdbi_databases[i].name;
300                 bdb->bi_databases[i] = db;
301         }
302
303         bdb->bi_databases[i] = NULL;
304         bdb->bi_ndatabases = i;
305
306         /* get nextid */
307         rc = bdb_last_id( be, NULL );
308         if( rc != 0 ) {
309                 Debug( LDAP_DEBUG_ANY,
310                         "bdb_db_open: last_id(%s) failed: %s (%d)\n",
311                         bdb->bi_dbenv_home, db_strerror(rc), rc );
312                 return rc;
313         }
314
315         if ( !( slapMode & SLAP_TOOL_QUICK )) {
316                 XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker);
317         }
318
319         /* If we're in server mode and time-based checkpointing is enabled,
320          * submit a task to perform periodic checkpoints.
321          */
322         if (( slapMode & SLAP_SERVER_MODE ) && bdb->bi_txn_cp &&
323                 bdb->bi_txn_cp_min )  {
324                 ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
325                 ldap_pvt_runqueue_insert( &slapd_rq, bdb->bi_txn_cp_min*60,
326                         bdb_checkpoint, bdb );
327                 ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
328         }
329
330         if ( slapMode & SLAP_SERVER_MODE && bdb->bi_db_has_config ) {
331                 char    buf[SLAP_TEXT_BUFLEN];
332                 FILE *f = fopen( bdb->bi_db_config_path, "r" );
333                 struct berval bv;
334
335                 if ( f ) {
336                         while ( fgets( buf, sizeof(buf), f )) {
337                                 ber_str2bv( buf, 0, 1, &bv );
338                                 if ( bv.bv_val[bv.bv_len-1] == '\n' ) {
339                                         bv.bv_len--;
340                                         bv.bv_val[bv.bv_len] = '\0';
341                                 }
342                                 /* shouldn't need this, but ... */
343                                 if ( bv.bv_val[bv.bv_len-1] == '\r' ) {
344                                         bv.bv_len--;
345                                         bv.bv_val[bv.bv_len] = '\0';
346                                 }
347                                 ber_bvarray_add( &bdb->bi_db_config, &bv );
348                         }
349                         fclose( f );
350                 } else {
351                         /* Eh? It disappeared between config and open?? */
352                         bdb->bi_db_has_config = 0;
353                 }
354
355         }
356         bdb->bi_db_is_open = 1;
357
358         return 0;
359 }
360
361 static int
362 bdb_db_close( BackendDB *be )
363 {
364         int rc;
365         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
366         struct bdb_db_info *db;
367         bdb_idl_cache_entry_t *entry, *next_entry;
368
369         bdb->bi_db_is_open = 0;
370
371         ber_bvarray_free( bdb->bi_db_config );
372
373         while( bdb->bi_ndatabases-- ) {
374                 db = bdb->bi_databases[bdb->bi_ndatabases];
375                 rc = db->bdi_db->close( db->bdi_db, 0 );
376                 /* Lower numbered names are not strdup'd */
377                 if( bdb->bi_ndatabases >= BDB_NDB )
378                         free( db->bdi_name );
379                 free( db );
380         }
381         free( bdb->bi_databases );
382         bdb_attr_index_destroy( bdb->bi_attrs );
383
384         bdb_cache_release_all (&bdb->bi_cache);
385
386         if ( bdb->bi_idl_cache_max_size ) {
387                 ldap_pvt_thread_rdwr_wlock ( &bdb->bi_idl_tree_rwlock );
388                 avl_free( bdb->bi_idl_tree, NULL );
389                 entry = bdb->bi_idl_lru_head;
390                 while ( entry != NULL ) {
391                         next_entry = entry->idl_lru_next;
392                         if ( entry->idl )
393                                 free( entry->idl );
394                         free( entry->kstr.bv_val );
395                         free( entry );
396                         entry = next_entry;
397                 }
398                 ldap_pvt_thread_rdwr_wunlock ( &bdb->bi_idl_tree_rwlock );
399         }
400
401         if ( !( slapMode & SLAP_TOOL_QUICK )) {
402                 XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
403         }
404
405         return 0;
406 }
407
408 static int
409 bdb_db_destroy( BackendDB *be )
410 {
411         int rc;
412         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
413
414         /* close db environment */
415         if( bdb->bi_dbenv ) {
416                 /* force a checkpoint */
417                 if ( !( slapMode & SLAP_TOOL_QUICK )) {
418                         rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
419                         if( rc != 0 ) {
420                                 Debug( LDAP_DEBUG_ANY,
421                                         "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
422                                         db_strerror(rc), rc, 0 );
423                         }
424                 }
425
426                 rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
427                 bdb->bi_dbenv = NULL;
428                 if( rc != 0 ) {
429                         Debug( LDAP_DEBUG_ANY,
430                                 "bdb_db_destroy: close failed: %s (%d)\n",
431                                 db_strerror(rc), rc, 0 );
432                         return rc;
433                 }
434         }
435
436         rc = alock_close( &bdb->bi_alock_info );
437         if( rc != 0 ) {
438                 Debug( LDAP_DEBUG_ANY,
439                         "bdb_db_destroy: alock_close failed\n", 0, 0, 0 );
440                 return -1;
441         }
442
443         if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home );
444         if( bdb->bi_db_config_path ) ch_free( bdb->bi_db_config_path );
445
446         ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock );
447         ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex );
448         ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_dntree.bei_kids_mutex );
449         ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
450         ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
451         if ( bdb->bi_idl_cache_max_size ) {
452                 ldap_pvt_thread_rdwr_destroy( &bdb->bi_idl_tree_rwlock );
453                 ldap_pvt_thread_mutex_destroy( &bdb->bi_idl_tree_lrulock );
454         }
455
456         ch_free( bdb );
457         be->be_private = NULL;
458
459         return 0;
460 }
461
462 int
463 bdb_back_initialize(
464         BackendInfo     *bi )
465 {
466         int rc;
467
468         static char *controls[] = {
469                 LDAP_CONTROL_ASSERT,
470                 LDAP_CONTROL_MANAGEDSAIT,
471                 LDAP_CONTROL_NOOP,
472                 LDAP_CONTROL_PAGEDRESULTS,
473 #ifdef LDAP_CONTROL_SUBENTRIES
474                 LDAP_CONTROL_SUBENTRIES,
475 #endif
476 #ifdef LDAP_CONTROL_X_PERMISSIVE_MODIFY
477                 LDAP_CONTROL_X_PERMISSIVE_MODIFY,
478 #endif
479                 NULL
480         };
481
482         /* initialize the underlying database system */
483         Debug( LDAP_DEBUG_TRACE,
484                 LDAP_XSTRING(bdb_back_initialize) ": initialize " 
485                 BDB_UCTYPE " backend\n", 0, 0, 0 );
486
487         bi->bi_flags |=
488                 SLAP_BFLAG_INCREMENT |
489 #ifdef BDB_SUBENTRIES
490                 SLAP_BFLAG_SUBENTRIES |
491 #endif
492                 SLAP_BFLAG_ALIASES |
493                 SLAP_BFLAG_REFERRALS;
494
495         bi->bi_controls = controls;
496
497         {       /* version check */
498                 int major, minor, patch, ver;
499                 char *version = db_version( &major, &minor, &patch );
500 #ifdef HAVE_EBCDIC
501                 char v2[1024];
502
503                 /* All our stdio does an ASCII to EBCDIC conversion on
504                  * the output. Strings from the BDB library are already
505                  * in EBCDIC; we have to go back and forth...
506                  */
507                 strcpy( v2, version );
508                 __etoa( v2 );
509                 version = v2;
510 #endif
511
512                 ver = (major << 24) | (minor << 16) | patch;
513                 if( ver != DB_VERSION_FULL ) {
514                         /* fail if a versions don't match */
515                         Debug( LDAP_DEBUG_ANY,
516                                 LDAP_XSTRING(bdb_back_initialize) ": "
517                                 "BDB library version mismatch:"
518                                 " expected " DB_VERSION_STRING ","
519                                 " got %s\n", version, 0, 0 );
520                         return -1;
521                 }
522
523                 Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_back_initialize)
524                         ": %s\n", version, 0, 0 );
525         }
526
527         db_env_set_func_free( ber_memfree );
528         db_env_set_func_malloc( (db_malloc *)ber_memalloc );
529         db_env_set_func_realloc( (db_realloc *)ber_memrealloc );
530 #ifndef NO_THREAD
531         /* This is a no-op on a NO_THREAD build. Leave the default
532          * alone so that BDB will sleep on interprocess conflicts.
533          */
534         db_env_set_func_yield( ldap_pvt_thread_yield );
535 #endif
536
537         bi->bi_open = 0;
538         bi->bi_close = 0;
539         bi->bi_config = 0;
540         bi->bi_destroy = 0;
541
542         bi->bi_db_init = bdb_db_init;
543         bi->bi_db_config = config_generic_wrapper;
544         bi->bi_db_open = bdb_db_open;
545         bi->bi_db_close = bdb_db_close;
546         bi->bi_db_destroy = bdb_db_destroy;
547
548         bi->bi_op_add = bdb_add;
549         bi->bi_op_bind = bdb_bind;
550         bi->bi_op_compare = bdb_compare;
551         bi->bi_op_delete = bdb_delete;
552         bi->bi_op_modify = bdb_modify;
553         bi->bi_op_modrdn = bdb_modrdn;
554         bi->bi_op_search = bdb_search;
555
556         bi->bi_op_unbind = 0;
557
558         bi->bi_extended = bdb_extended;
559
560         bi->bi_chk_referrals = bdb_referrals;
561         bi->bi_operational = bdb_operational;
562         bi->bi_has_subordinates = bdb_hasSubordinates;
563         bi->bi_entry_release_rw = bdb_entry_release;
564         bi->bi_entry_get_rw = bdb_entry_get;
565
566         /*
567          * hooks for slap tools
568          */
569         bi->bi_tool_entry_open = bdb_tool_entry_open;
570         bi->bi_tool_entry_close = bdb_tool_entry_close;
571         bi->bi_tool_entry_first = bdb_tool_entry_next;
572         bi->bi_tool_entry_next = bdb_tool_entry_next;
573         bi->bi_tool_entry_get = bdb_tool_entry_get;
574         bi->bi_tool_entry_put = bdb_tool_entry_put;
575         bi->bi_tool_entry_reindex = bdb_tool_entry_reindex;
576         bi->bi_tool_sync = 0;
577         bi->bi_tool_dn2id_get = bdb_tool_dn2id_get;
578         bi->bi_tool_id2entry_get = bdb_tool_id2entry_get;
579         bi->bi_tool_entry_modify = bdb_tool_entry_modify;
580
581         bi->bi_connection_init = 0;
582         bi->bi_connection_destroy = 0;
583
584         rc = bdb_back_init_cf( bi );
585
586         return rc;
587 }
588
589 #if     (SLAPD_BDB == SLAPD_MOD_DYNAMIC && !defined(BDB_HIER)) || \
590         (SLAPD_HDB == SLAPD_MOD_DYNAMIC && defined(BDB_HIER))
591
592 /* conditionally define the init_module() function */
593 #ifdef BDB_HIER
594 SLAP_BACKEND_INIT_MODULE( hdb )
595 #else /* !BDB_HIER */
596 SLAP_BACKEND_INIT_MODULE( bdb )
597 #endif /* !BDB_HIER */
598
599 #endif /* SLAPD_[BH]DB == SLAPD_MOD_DYNAMIC */
600