Commit cc93cf8e authored by Howard Chu's avatar Howard Chu Committed by Quanah Gibson-Mount
Browse files

ITS#7906,#7923 Don't free configinfo in _db_close

parent 65565616
......@@ -199,20 +199,6 @@ auditlog_db_init(
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,
......@@ -223,6 +209,7 @@ auditlog_db_destroy(
auditlog_data *ad = on->on_bi.bi_private;
ldap_pvt_thread_mutex_destroy( &ad->ad_mutex );
free( ad->ad_logfile );
free( ad );
return 0;
}
......@@ -232,7 +219,6 @@ int auditlog_initialize() {
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;
......
......@@ -1161,7 +1161,7 @@ mod_violation:
}
static int
constraint_close(
constraint_destroy(
BackendDB *be,
ConfigReply *cr )
{
......@@ -1186,7 +1186,7 @@ constraint_initialize( void ) {
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;
......
......@@ -1784,6 +1784,7 @@ dds_db_close(
}
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 );
......
......@@ -181,7 +181,7 @@ dyngroup_response( Operation *op, SlapReply *rs )
}
static int
dyngroup_close(
dyngroup_destroy(
BackendDB *be,
ConfigReply *cr
)
......@@ -207,7 +207,7 @@ int dyngroup_initialize() {
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;
......
......@@ -4783,7 +4783,7 @@ pcache_db_close(
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 ) {
......@@ -4793,6 +4793,7 @@ pcache_db_close(
}
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 ) {
......@@ -4864,10 +4865,35 @@ pcache_db_close(
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;
......@@ -4905,29 +4931,6 @@ pcache_db_close(
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 );
......
......@@ -314,8 +314,21 @@ refint_db_destroy(
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);
......@@ -349,11 +362,8 @@ refint_open(
/*
** foreach configured attribute:
** free it;
** free our basedn;
** reset on_bi.bi_private;
** free our config data;
** free our refintdn
**
*/
......@@ -365,20 +375,9 @@ refint_close(
{
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 );
......
......@@ -168,6 +168,7 @@ seqmod_db_close(
ldap_pvt_thread_mutex_destroy( &sm->sm_mutex );
ch_free( sm );
on->on_bi.bi_private = NULL;
}
return 0;
......
......@@ -149,4 +149,10 @@ servers to be cached locally. In both cases the overlays must provide a bit of
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.
---
......@@ -823,47 +823,6 @@ unique_db_destroy(
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
......@@ -1465,8 +1424,6 @@ unique_initialize()
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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment