(void) memset ((void *) &slot_data, 0, sizeof (alock_slot_t));
alock_read_slot (info, &slot_data);
- if (slot_data.al_lock == ALOCK_UNLOCKED) return ALOCK_UNLOCKED;
if (slot_data.al_appname != NULL) free (slot_data.al_appname);
slot_data.al_appname = NULL;
+ if (slot_data.al_lock == ALOCK_UNLOCKED) return ALOCK_UNLOCKED;
+
res = alock_test_lock (info->al_fd, info->al_slot);
if (res < 0) return -1;
if (res > 0) {
)
{
struct ldif_info *ni = be->be_private;
+
+ ch_free(ni->li_base_path.bv_val);
ldap_pvt_thread_mutex_destroy(&ni->li_mutex);
free( be->be_private );
return 0;
return 0;
}
-void backend_destroy_one( BackendDB *bd )
+void backend_destroy_one( BackendDB *bd, int dynamic )
{
- LDAP_STAILQ_REMOVE(&backendDB, bd, slap_backend_db, be_next );
+ if ( dynamic ) {
+ LDAP_STAILQ_REMOVE(&backendDB, bd, slap_backend_db, be_next );
+ }
if ( bd->be_syncinfo ) {
syncinfo_free( bd->be_syncinfo );
csne = LDAP_TAILQ_NEXT( csne, ce_csn_link );
ch_free( tmp_csne );
}
+ ch_free( bd->be_pending_csn_list );
}
if ( bd->bd_info->bi_db_destroy ) {
free( bd->be_rootpw.bv_val );
}
acl_destroy( bd->be_acl, frontendDB->be_acl );
- free( bd );
+ if ( dynamic ) {
+ free( bd );
+ }
}
int backend_destroy(void)
/* destroy each backend database */
while (( bd = LDAP_STAILQ_FIRST(&backendDB))) {
- backend_destroy_one( bd );
+ backend_destroy_one( bd, 1 );
}
/* destroy each backend type */
op->o_bd = &cfb->cb_db;
rc = op->o_bd->be_search( op, &rs );
+
+ slap_sl_mem_destroy( NULL, op->o_tmpmemctx );
}
cfb->cb_use_ldif = 1;
leave:
if ( rc ) {
if ( (colst[0]->co_type == Cft_Database) && ca->be ) {
- backend_destroy_one( ca->be );
+ backend_destroy_one( ca->be, 1 );
} else if ( (colst[0]->co_type == Cft_Overlay) && ca->bi ) {
overlay_destroy_one( ca->be, (slap_overinst *)ca->bi );
}
}
}
}
+ if ( op )
+ slap_sl_mem_destroy( NULL, op->o_tmpmemctx );
return 0;
}
{
CfBackInfo *cfb = be->be_private;
- /* Note - this is asymmetric; cfb->cb_config was allocated in db_init
- * not db_open. We cannot re-open this DB after a close. (Not that we
- * ever could anyway.)
- */
- cfb_free_cffile( cfb->cb_config );
- cfb->cb_config = NULL;
-
cfb_free_entries( cfb->cb_root );
cfb->cb_root = NULL;
+
+ backend_shutdown( &cfb->cb_db );
return 0;
}
static int
config_back_db_destroy( BackendDB *be )
{
+ CfBackInfo *cfb = be->be_private;
+
+ cfb_free_cffile( cfb->cb_config );
+
+ ch_free( cfdir.bv_val );
+
+ avl_free( CfOcTree, NULL );
+
+ cfb->cb_db.be_suffix = NULL;
+ cfb->cb_db.be_nsuffix = NULL;
+ cfb->cb_db.be_rootdn.bv_val = NULL;
+ cfb->cb_db.be_rootndn.bv_val = NULL;
+ backend_destroy_one( &cfb->cb_db, 0 );
+
free( be->be_private );
return 0;
}
LDAP_SLAPD_F (int) backend_sync LDAP_P((Backend *be));
LDAP_SLAPD_F (int) backend_shutdown LDAP_P((Backend *be));
LDAP_SLAPD_F (int) backend_destroy LDAP_P((void));
-LDAP_SLAPD_F (void) backend_destroy_one LDAP_P((BackendDB *bd));
+LDAP_SLAPD_F (void) backend_destroy_one LDAP_P((BackendDB *bd, int dynamic));
LDAP_SLAPD_F (BackendInfo *) backend_info LDAP_P(( const char *type ));
LDAP_SLAPD_F (BackendDB *) backend_db_init LDAP_P(( const char *type ));
if ( indexes[0] != 0 || indexes[vals-1] != vals-1 ) {
renumber = 1;
}
+ ch_free( indexes );
} else {
renumber = 1;
}