return 0;
}
-static int
-auditlog_db_close(
- BackendDB *be,
- ConfigReply *cr
-)
-{
- slap_overinst *on = (slap_overinst *)be->bd_info;
- auditlog_data *ad = on->on_bi.bi_private;
-
- free( ad->ad_logfile );
- ad->ad_logfile = NULL;
- return 0;
-}
-
static int
auditlog_db_destroy(
BackendDB *be,
auditlog_data *ad = on->on_bi.bi_private;
ldap_pvt_thread_mutex_destroy( &ad->ad_mutex );
+ free( ad->ad_logfile );
free( ad );
return 0;
}
auditlog.on_bi.bi_type = "auditlog";
auditlog.on_bi.bi_db_init = auditlog_db_init;
- auditlog.on_bi.bi_db_close = auditlog_db_close;
auditlog.on_bi.bi_db_destroy = auditlog_db_destroy;
auditlog.on_response = auditlog_response;
}
static int
-constraint_close(
+constraint_destroy(
BackendDB *be,
ConfigReply *cr )
{
int rc;
constraint_ovl.on_bi.bi_type = "constraint";
- constraint_ovl.on_bi.bi_db_close = constraint_close;
+ constraint_ovl.on_bi.bi_db_destroy = constraint_destroy;
constraint_ovl.on_bi.bi_op_add = constraint_add;
constraint_ovl.on_bi.bi_op_modify = constraint_update;
constraint_ovl.on_bi.bi_op_modrdn = constraint_update;
}
ldap_pvt_runqueue_remove( &slapd_rq, di->di_expire_task );
ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
+ di->di_expire_task = NULL;
}
(void)entry_info_unregister( dds_entry_info, (void *)di );
}
static int
-dyngroup_close(
+dyngroup_destroy(
BackendDB *be,
ConfigReply *cr
)
int code;
dyngroup.on_bi.bi_type = "dyngroup";
- dyngroup.on_bi.bi_db_close = dyngroup_close;
+ dyngroup.on_bi.bi_db_destroy = dyngroup_destroy;
dyngroup.on_response = dyngroup_response;
dyngroup.on_bi.bi_cf_ocs = dgroupocs;
cache_manager *cm = on->on_bi.bi_private;
query_manager *qm = cm->qm;
QueryTemplate *tm;
- int i, rc = 0;
+ int rc = 0;
/* stop the thread ... */
if ( cm->cc_arg ) {
}
ldap_pvt_runqueue_remove( &slapd_rq, cm->cc_arg );
ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
+ cm->cc_arg = NULL;
}
if ( cm->save_queries ) {
cm->db.be_limits = NULL;
cm->db.be_acl = NULL;
-
if ( cm->db.bd_info->bi_db_close ) {
rc = cm->db.bd_info->bi_db_close( &cm->db, NULL );
}
+
+#ifdef PCACHE_MONITOR
+ if ( rc == LDAP_SUCCESS ) {
+ rc = pcache_monitor_db_close( be );
+ }
+#endif /* PCACHE_MONITOR */
+
+ return rc;
+}
+
+static int
+pcache_db_destroy(
+ BackendDB *be,
+ ConfigReply *cr
+)
+{
+ slap_overinst *on = (slap_overinst *)be->bd_info;
+ cache_manager *cm = on->on_bi.bi_private;
+ query_manager *qm = cm->qm;
+ QueryTemplate *tm;
+ int i;
+
+ if ( cm->db.be_private != NULL ) {
+ backend_stopdown_one( &cm->db );
+ }
+
while ( (tm = qm->templates) != NULL ) {
CachedQuery *qc, *qn;
qm->templates = tm->qmnext;
free( qm->attr_sets );
qm->attr_sets = NULL;
-#ifdef PCACHE_MONITOR
- if ( rc == LDAP_SUCCESS ) {
- rc = pcache_monitor_db_close( be );
- }
-#endif /* PCACHE_MONITOR */
-
- return rc;
-}
-
-static int
-pcache_db_destroy(
- BackendDB *be,
- ConfigReply *cr
-)
-{
- slap_overinst *on = (slap_overinst *)be->bd_info;
- cache_manager *cm = on->on_bi.bi_private;
- query_manager *qm = cm->qm;
-
- if ( cm->db.be_private != NULL ) {
- backend_stopdown_one( &cm->db );
- }
-
ldap_pvt_thread_mutex_destroy( &qm->lru_mutex );
ldap_pvt_thread_mutex_destroy( &cm->cache_mutex );
free( qm );
if ( on->on_bi.bi_private ) {
refint_data *id = on->on_bi.bi_private;
+ refint_attrs *ii, *ij;
+
on->on_bi.bi_private = NULL;
ldap_pvt_thread_mutex_destroy( &id->qmutex );
+
+ for(ii = id->attrs; ii; ii = ij) {
+ ij = ii->next;
+ ch_free(ii);
+ }
+
+ ch_free( id->nothing.bv_val );
+ BER_BVZERO( &id->nothing );
+ ch_free( id->nnothing.bv_val );
+ BER_BVZERO( &id->nnothing );
+
ch_free( id );
}
return(0);
/*
-** foreach configured attribute:
-** free it;
** free our basedn;
-** reset on_bi.bi_private;
-** free our config data;
+** free our refintdn
**
*/
{
slap_overinst *on = (slap_overinst *) be->bd_info;
refint_data *id = on->on_bi.bi_private;
- refint_attrs *ii, *ij;
-
- for(ii = id->attrs; ii; ii = ij) {
- ij = ii->next;
- ch_free(ii);
- }
- id->attrs = NULL;
ch_free( id->dn.bv_val );
BER_BVZERO( &id->dn );
- ch_free( id->nothing.bv_val );
- BER_BVZERO( &id->nothing );
- ch_free( id->nnothing.bv_val );
- BER_BVZERO( &id->nnothing );
ch_free( id->refint_dn.bv_val );
BER_BVZERO( &id->refint_dn );
ch_free( id->refint_ndn.bv_val );
ldap_pvt_thread_mutex_destroy( &sm->sm_mutex );
ch_free( sm );
+ on->on_bi.bi_private = NULL;
}
return 0;
glue to swap in the appropriate be_private and bd_info pointers before invoking
the attached backend, which can then be invoked as usual.
+Note on overlay initialization/destruction: you should allocate storage for
+config info in the _db_init handler, and free this storage in the _db_destroy
+handler. You must not free it in the _db_close handler because a module may
+be opened/closed multiple times in a running slapd when using dynamic
+configuration and the config info must remain intact.
+
---
return 0;
}
-static int
-unique_open(
- BackendDB *be,
- ConfigReply *cr
-)
-{
- Debug(LDAP_DEBUG_TRACE, "unique_open: overlay initialized\n", 0, 0, 0);
-
- return 0;
-}
-
-
-/*
-** Leave unique_data but wipe out config
-**
-*/
-
-static int
-unique_close(
- BackendDB *be,
- ConfigReply *cr
-)
-{
- slap_overinst *on = (slap_overinst *) be->bd_info;
- unique_data **privatep = (unique_data **) &on->on_bi.bi_private;
- unique_data *private = *privatep;
-
- Debug(LDAP_DEBUG_TRACE, "==> unique_close\n", 0, 0, 0);
-
- if ( private ) {
- unique_domain *domains = private->domains;
- unique_domain *legacy = private->legacy;
-
- unique_free_domain ( domains );
- unique_free_domain ( legacy );
- memset ( private, 0, sizeof ( unique_data ) );
- }
-
- return ( 0 );
-}
-
/*
** search callback
unique.on_bi.bi_type = "unique";
unique.on_bi.bi_db_init = unique_db_init;
unique.on_bi.bi_db_destroy = unique_db_destroy;
- unique.on_bi.bi_db_open = unique_open;
- unique.on_bi.bi_db_close = unique_close;
unique.on_bi.bi_op_add = unique_add;
unique.on_bi.bi_op_modify = unique_modify;
unique.on_bi.bi_op_modrdn = unique_modrdn;