1 /* init.c - initialize ldbm backend */
11 #include "back-ldbm.h"
18 bi->bi_open = ldbm_back_open;
20 bi->bi_close = ldbm_back_close;
21 bi->bi_destroy = ldbm_back_destroy;
23 bi->bi_db_init = ldbm_back_db_init;
24 bi->bi_db_config = ldbm_back_db_config;
25 bi->bi_db_open = ldbm_back_db_open;
26 bi->bi_db_close = ldbm_back_db_close;
27 bi->bi_db_destroy = ldbm_back_db_destroy;
29 bi->bi_op_bind = ldbm_back_bind;
30 bi->bi_op_unbind = ldbm_back_unbind;
31 bi->bi_op_search = ldbm_back_search;
32 bi->bi_op_compare = ldbm_back_compare;
33 bi->bi_op_modify = ldbm_back_modify;
34 bi->bi_op_modrdn = ldbm_back_modrdn;
35 bi->bi_op_add = ldbm_back_add;
36 bi->bi_op_delete = ldbm_back_delete;
37 bi->bi_op_abandon = ldbm_back_abandon;
39 bi->bi_entry_release_rw = ldbm_back_entry_release_rw;
40 #ifdef SLAPD_ACLGROUPS
41 bi->bi_acl_group = ldbm_back_group;
62 /* initialize the underlying database system */
63 rc = ldbm_initialize();
73 /* terminate the underlying database system */
87 /* allocate backend-database-specific stuff */
88 li = (struct ldbminfo *) ch_calloc( 1, sizeof(struct ldbminfo) );
90 /* arrange to read nextid later (on first request for it) */
93 #if SLAPD_NEXTID_CHUNK > 1
94 li->li_nextid_wrote = NOID;
97 /* default cache size */
98 li->li_cache.c_maxsize = DEFAULT_CACHE_SIZE;
100 /* default database cache size */
101 li->li_dbcachesize = DEFAULT_DBCACHE_SIZE;
103 /* default cache mode is sync on write */
104 li->li_dbcachewsync = 1;
106 /* default file creation mode */
107 li->li_mode = DEFAULT_MODE;
109 /* default database directory */
110 li->li_directory = ch_strdup( DEFAULT_DB_DIRECTORY );
112 /* always index dn, id2children, objectclass (used in some searches) */
116 attr_syntax_config( "ldbm dn initialization", 0, 2, argv );
121 attr_index_config( li, "ldbm dn initialization", 0, 3, argv, 1 );
122 argv[ 0 ] = "id2children";
125 attr_index_config( li, "ldbm id2children initialization", 0, 2, argv,
127 argv[ 0 ] = "objectclass";
128 argv[ 1 ] = ch_strdup( "pres,eq" );
130 attr_index_config( li, "ldbm objectclass initialization", 0, 2, argv,
134 /* initialize various mutex locks & condition variables */
135 ldap_pvt_thread_mutex_init( &li->li_root_mutex );
136 ldap_pvt_thread_mutex_init( &li->li_add_mutex );
137 ldap_pvt_thread_mutex_init( &li->li_cache.c_mutex );
138 ldap_pvt_thread_mutex_init( &li->li_nextid_mutex );
139 ldap_pvt_thread_mutex_init( &li->li_dbcache_mutex );
140 ldap_pvt_thread_cond_init( &li->li_dbcache_cv );
156 ldbm_back_db_destroy(
160 /* should free/destroy every in be_private */
162 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
163 free( li->li_nextid_file );
164 free( li->li_directory );
165 attr_index_destroy( li->li_attrs );
167 ldap_pvt_thread_mutex_destroy( &li->li_root_mutex );
168 ldap_pvt_thread_mutex_destroy( &li->li_add_mutex );
169 ldap_pvt_thread_mutex_destroy( &li->li_cache.c_mutex );
170 ldap_pvt_thread_mutex_destroy( &li->li_nextid_mutex );
171 ldap_pvt_thread_mutex_destroy( &li->li_dbcache_mutex );
172 ldap_pvt_thread_cond_destroy( &li->li_dbcache_cv );
173 #endif /* SLAP_CLEANUP */
174 free( be->be_private );
175 be->be_private = NULL;