1 /* init.c - initialize bdb2 backend */
12 #include "back-bdb2.h"
14 #ifdef SLAPD_BDB2_DYNAMIC
16 int back_bdb2_LTX_init_module(int argc, char *argv[]) {
19 memset( &bi, 0, sizeof(bi) );
21 bi.bi_init = bdb2_back_initialize;
27 #endif /* SLAPD_BDB2_DYNAMIC */
30 bdb2i_back_init_private(
36 /* allocate backend-type-specific stuff */
37 bt = (struct ldbtype *) ch_calloc( 1, sizeof(struct ldbtype) );
39 bt->lty_dbhome = DEFAULT_DB_HOME;
40 bt->lty_mpsize = DEFAULT_DBCACHE_SIZE;
42 if ( slapMode & SLAP_TIMED_MODE )
58 static char *controls[] = {
59 LDAP_CONTROL_MANAGEDSAIT,
60 /* LDAP_CONTROL_X_CHANGE_PASSWD, */
64 bi->bi_controls = controls;
66 bi->bi_open = bdb2_back_open;
67 bi->bi_config = bdb2_back_config;
68 bi->bi_close = bdb2_back_close;
69 bi->bi_destroy = bdb2_back_destroy;
71 bi->bi_db_init = bdb2_back_db_init;
72 bi->bi_db_config = bdb2_back_db_config;
73 bi->bi_db_open = bdb2_back_db_open;
74 bi->bi_db_close = bdb2_back_db_close;
75 bi->bi_db_destroy = bdb2_back_db_destroy;
77 bi->bi_op_bind = bdb2_back_bind;
78 bi->bi_op_unbind = bdb2_back_unbind;
79 bi->bi_op_search = bdb2_back_search;
80 bi->bi_op_compare = bdb2_back_compare;
81 bi->bi_op_modify = bdb2_back_modify;
82 bi->bi_op_modrdn = bdb2_back_modrdn;
83 bi->bi_op_add = bdb2_back_add;
84 bi->bi_op_delete = bdb2_back_delete;
85 bi->bi_op_abandon = bdb2_back_abandon;
89 bi->bi_entry_release_rw = bdb2_back_entry_release_rw;
90 bi->bi_acl_group = bdb2_back_group;
93 * hooks for slap tools
95 bi->bi_tool_entry_open = bdb2_tool_entry_open;
96 bi->bi_tool_entry_close = bdb2_tool_entry_close;
97 bi->bi_tool_entry_first = bdb2_tool_entry_first;
98 bi->bi_tool_entry_next = bdb2_tool_entry_next;
99 bi->bi_tool_entry_get = bdb2_tool_entry_get;
100 bi->bi_tool_entry_put = bdb2_tool_entry_put;
101 bi->bi_tool_index_attr = bdb2_tool_index_attr;
102 bi->bi_tool_index_change = bdb2_tool_index_change;
103 bi->bi_tool_sync = bdb2_tool_sync;
105 #ifdef HAVE_CYRUS_SASL
106 bi->bi_sasl_authorize = 0;
107 bi->bi_sasl_getsecret = 0;
108 bi->bi_sasl_putsecret = 0;
109 #endif /* HAVE_CYRUS_SASL */
111 bi->bi_connection_init = 0;
112 bi->bi_connection_destroy = 0;
114 ret = bdb2i_back_init_private( bi );
116 Debug( LDAP_DEBUG_TRACE, "bdb2_back_initialize: done (%d).\n", ret, 0, 0 );
134 static int initialized = 0;
137 if ( initialized++ ) {
139 Debug( LDAP_DEBUG_TRACE,
140 "bdb2_back_open: backend already initialized.\n", 0, 0, 0 );
145 /* initialize the underlying database system */
146 rc = bdb2i_back_startup( bi );
158 /* close the underlying database system */
159 rc = bdb2i_back_shutdown( bi );
166 bdb2i_back_db_init_internal(
173 /* allocate backend-database-specific stuff */
174 li = (struct ldbminfo *) ch_calloc( 1, sizeof(struct ldbminfo) );
176 /* arrange to read nextid later (on first request for it) */
177 li->li_nextid = NOID;
178 #if SLAPD_NEXTID_CHUNK > 1
179 li->li_nextid_wrote = NOID;
182 /* default cache size */
183 li->li_cache.c_maxsize = DEFAULT_CACHE_SIZE;
185 /* default database cache size */
186 li->li_dbcachesize = DEFAULT_DBCACHE_SIZE;
188 /* default file creation mode */
189 li->li_mode = DEFAULT_MODE;
191 /* default database directory */
192 li->li_directory = DEFAULT_DB_DIRECTORY;
194 argv[ 0 ] = "objectclass";
197 bdb2i_attr_index_config( li, "ldbm objectclass initialization",
200 /* initialize the cache mutex */
201 ldap_pvt_thread_mutex_init( &li->li_cache.c_mutex );
203 /* initialize the TP file head */
204 if ( bdb2i_txn_head_init( &li->li_txn_head ) != 0 )
218 struct timeval time1;
221 bdb2i_start_timing( be->bd_info, &time1 );
223 ret = bdb2i_back_db_init_internal( be );
224 bdb2i_stop_timing( be->bd_info, time1, "DB-INIT", NULL, NULL );
237 rc = bdb2_back_db_startup( be );
243 bdb2_back_db_destroy(
247 /* should free/destroy every in be_private */
248 free( be->be_private );
249 be->be_private = NULL;