Exemplo n.º 1
0
/* Destroy the context, or if key==NULL clean it up for reuse. */
void
slap_sl_mem_destroy(
	void *key,
	void *data
)
{
	struct slab_heap *sh = data;
	struct slab_object *so;
	int i;

	if (!sh->sh_stack) {
		for (i = 0; i <= sh->sh_maxorder - order_start; i++) {
			so = LDAP_LIST_FIRST(&sh->sh_free[i]);
			while (so) {
				struct slab_object *so_tmp = so;
				so = LDAP_LIST_NEXT(so, so_link);
				LDAP_LIST_INSERT_HEAD(&sh->sh_sopool, so_tmp, so_link);
			}
			ch_free(sh->sh_map[i]);
		}
		ch_free(sh->sh_free);
		ch_free(sh->sh_map);

		so = LDAP_LIST_FIRST(&sh->sh_sopool);
		while (so) {
			struct slab_object *so_tmp = so;
			so = LDAP_LIST_NEXT(so, so_link);
			if (!so_tmp->so_blockhead) {
				LDAP_LIST_REMOVE(so_tmp, so_link);
			}
		}
		so = LDAP_LIST_FIRST(&sh->sh_sopool);
		while (so) {
			struct slab_object *so_tmp = so;
			so = LDAP_LIST_NEXT(so, so_link);
			ch_free(so_tmp);
		}
	}

	if (key != NULL) {
		ber_memfree_x(sh->sh_base, NULL);
		ber_memfree_x(sh, NULL);
	}
}
Exemplo n.º 2
0
static unsigned long autoPosixIds_next_available( Operation *op ) {

	slap_overinst* on = (slap_overinst *)op->o_bd->bd_info;
	autoPosixIds_data* ad = on->on_bi.bi_private;

	Operation nop = *op;
	SlapReply nrs = { REP_RESULT };
	Filter* filter = NULL;
	slap_callback cb = { NULL, autoPosixIds_search_cb, NULL, ad };
	struct berval fstr = BER_BVNULL;
	struct berval rootstr = BER_BVNULL;
  	int rc;

	// if max uid is known don't bother searching the tree
	if( ad->max_uid_number == 0 ) {

	    nop.o_callback = &cb;
	    op->o_bd->bd_info = (BackendInfo *) on->on_info;
	    nop.o_tag = LDAP_REQ_SEARCH;
	    nop.o_ctrls = NULL;
		
	    filter = str2filter( "(uidNumber=*)" );
	    filter2bv( filter, &fstr );

	    nop.ors_scope = LDAP_SCOPE_SUBTREE;
	    nop.ors_deref = LDAP_DEREF_NEVER;
	    nop.ors_slimit = -1;//SLAP_NO_LIMIT;
	    nop.ors_tlimit = -1;//SLAP_NO_LIMIT;
	    nop.ors_attrsonly = 1;
	    nop.ors_attrs = slap_anlist_no_attrs;
	    nop.ors_filter = filter;
	    nop.ors_filterstr = fstr;

	    memset( &nrs, 0, sizeof(nrs) );
	    nrs.sr_type = REP_RESULT;
	    nrs.sr_err = LDAP_SUCCESS;
	    nrs.sr_entry = NULL;
	    nrs.sr_flags |= REP_ENTRY_MUSTBEFREED;
	    nrs.sr_text = NULL;

	    nop.o_req_dn = rootstr;
	    nop.o_req_ndn = rootstr;

	    if( nop.o_bd->be_search ) {
		rc = nop.o_bd->be_search( &nop, &nrs );
		Debug( LDAP_DEBUG_TRACE, "%s: finished searching for entries with uidNumber\n", autoPosixIds.on_bi.bi_type, 0, 0 );
	    }
	    else {
		Debug( LDAP_DEBUG_ANY, "%s: backend missing search function\n", autoPosixIds.on_bi.bi_type, 0, 0 );
	    }

	    if( filter ) filter_free( filter );
	    if( fstr.bv_val ) ch_free( fstr.bv_val );
	}
	return ++(ad->max_uid_number);
}
Exemplo n.º 3
0
int bdb_entry_return(
	Entry *e )
{
	/* Our entries are allocated in two blocks; the data comes from
	 * the db itself and the Entry structure and associated pointers
	 * are allocated in entry_decode. The db data pointer is saved
	 * in e_bv. Since the Entry structure is allocated as a single
	 * block, e_attrs is always a fixed offset from e. The exception
	 * is when an entry has been modified, in which case we also need
	 * to free e_attrs.
	 */
	if( !e->e_bv.bv_val ) {	/* A regular entry, from do_add */
		entry_free( e );
		return 0;
	}
	if( (void *) e->e_attrs != (void *) (e+1)) {
		attrs_free( e->e_attrs );
	}

#ifndef BDB_HIER
	/* See if the DNs were changed by modrdn */
	if( e->e_nname.bv_val < e->e_bv.bv_val || e->e_nname.bv_val >
		e->e_bv.bv_val + e->e_bv.bv_len ) {
		ch_free(e->e_name.bv_val);
		ch_free(e->e_nname.bv_val);
		e->e_name.bv_val = NULL;
		e->e_nname.bv_val = NULL;
	}
#else
	/* We had to construct the dn and ndn as well, in a single block */
	if( e->e_name.bv_val ) {
		free( e->e_name.bv_val );
	}
#endif
	/* In tool mode the e_bv buffer is realloc'd, leave it alone */
	if( !(slapMode & SLAP_TOOL_MODE) ) {
		free( e->e_bv.bv_val );
	}

	free( e );

	return 0;
}
Exemplo n.º 4
0
/*
 * I don't like this much, but we need two different
 * functions because different heap managers may be
 * in use in back-ldap/meta to reduce the amount of
 * calls to malloc routines, and some of the free()
 * routines may be macros with args
 */
int
ldap_dnattr_rewrite(
	dncookie		*dc,
	BerVarray		a_vals
)
{
	struct berval	bv;
	int		i, last;

	assert( a_vals != NULL );

	for ( last = 0; !BER_BVISNULL( &a_vals[last] ); last++ )
		;
	last--;

	for ( i = 0; !BER_BVISNULL( &a_vals[i] ); i++ ) {
		switch ( ldap_back_dn_massage( dc, &a_vals[i], &bv ) ) {
		case LDAP_UNWILLING_TO_PERFORM:
			/*
			 * FIXME: need to check if it may be considered 
			 * legal to trim values when adding/modifying;
			 * it should be when searching (e.g. ACLs).
			 */
			ch_free( a_vals[i].bv_val );
			if ( last > i ) {
				a_vals[i] = a_vals[last];
			}
			BER_BVZERO( &a_vals[last] );
			last--;
			break;

		default:
			/* leave attr untouched if massage failed */
			if ( !BER_BVISNULL( &bv ) && bv.bv_val != a_vals[i].bv_val ) {
				ch_free( a_vals[i].bv_val );
				a_vals[i] = bv;
			}
			break;
		}
	}
	
	return 0;
}
Exemplo n.º 5
0
int
backsql_merge_from_clause( 
	backsql_info	*bi,
	struct berbuf	*dest_from,
	struct berval	*src_from )
{
	char		*s, *p, *srcc, *pos, e;
	struct berbuf	res = BB_NULL;

#ifdef BACKSQL_TRACE
	Debug( LDAP_DEBUG_TRACE, "==>backsql_merge_from_clause(): "
		"dest_from=\"%s\",src_from=\"%s\"\n",
 		dest_from ? dest_from->bb_val.bv_val : "<NULL>",
		src_from->bv_val, 0 );
#endif /* BACKSQL_TRACE */

	srcc = ch_strdup( src_from->bv_val );
	p = srcc;

	if ( dest_from != NULL ) {
		res = *dest_from;
	}
	
	while ( *p ) {
		s = backsql_get_table_spec( bi, &p );

#ifdef BACKSQL_TRACE
		Debug( LDAP_DEBUG_TRACE, "backsql_merge_from_clause(): "
			"p=\"%s\" s=\"%s\"\n", p, s, 0 );
#endif /* BACKSQL_TRACE */

		if ( BER_BVISNULL( &res.bb_val ) ) {
			backsql_strcat_x( &res, NULL, s, NULL );

		} else {
			pos = strstr( res.bb_val.bv_val, s );
			if ( pos == NULL || ( ( e = pos[ strlen( s ) ] ) != '\0' && e != ',' ) ) {
				backsql_strfcat_x( &res, NULL, "cs", ',', s );
			}
		}
		
		if ( s ) {
			ch_free( s );
		}
	}

#ifdef BACKSQL_TRACE
	Debug( LDAP_DEBUG_TRACE, "<==backsql_merge_from_clause()\n", 0, 0, 0 );
#endif /* BACKSQL_TRACE */

	free( srcc );
	*dest_from = res;

	return 1;
}
Exemplo n.º 6
0
AttributeName*
file2anlist( AttributeName *an, const char *fname, const char *brkstr )
{
	FILE	*fp;
	char	*line = NULL;
	char	*lcur = NULL;
	char	*c;
	size_t	lmax = LBUFSIZ;

	fp = fopen( fname, "r" );
	if ( fp == NULL ) {
		Debug( LDAP_DEBUG_ANY,
			"get_attrs_from_file: failed to open attribute list file "
			"\"%s\": %s\n", fname, STRERROR(errno) );
		return NULL;
	}

	lcur = line = (char *) ch_malloc( lmax );
	if ( !line ) {
		Debug( LDAP_DEBUG_ANY,
			"get_attrs_from_file: could not allocate memory\n" );
		fclose(fp);
		return NULL;
	}

	while ( fgets( lcur, LBUFSIZ, fp ) != NULL ) {
		if ( ( c = strchr( lcur, '\n' ) ) ) {
			if ( c == line ) {
				*c = '\0';
			} else if ( *(c-1) == '\r' ) {
				*(c-1) = '\0';
			} else {
				*c = '\0';
			}
		} else {
			lmax += LBUFSIZ;
			line = (char *) ch_realloc( line, lmax );
			if ( !line ) {
				Debug( LDAP_DEBUG_ANY,
					"get_attrs_from_file: could not allocate memory\n" );
				fclose(fp);
				return NULL;
			}
			lcur = line + strlen( line );
			continue;
		}
		an = str2anlist( an, line, brkstr );
		if ( an == NULL )
			break;
		lcur = line;
	}
	ch_free( line );
	fclose(fp);
	return an;
}
Exemplo n.º 7
0
static int
bdb_db_destroy( BackendDB *be, ConfigReply *cr )
{
	struct bdb_info *bdb = (struct bdb_info *) be->be_private;

	/* stop and remove checkpoint task */
	if ( bdb->bi_txn_cp_task ) {
		struct re_s *re = bdb->bi_txn_cp_task;
		bdb->bi_txn_cp_task = NULL;
		ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
		if ( ldap_pvt_runqueue_isrunning( &slapd_rq, re ) )
			ldap_pvt_runqueue_stoptask( &slapd_rq, re );
		ldap_pvt_runqueue_remove( &slapd_rq, re );
		ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
	}

	/* monitor handling */
	(void)bdb_monitor_db_destroy( be );

	if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home );
	if( bdb->bi_db_config_path ) ch_free( bdb->bi_db_config_path );

	bdb_attr_index_destroy( bdb );

	ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock );
	ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_lru_mutex );
	ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_count_mutex );
	ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_eifree_mutex );
	ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_dntree.bei_kids_mutex );
#ifdef BDB_HIER
	ldap_pvt_thread_mutex_destroy( &bdb->bi_modrdns_mutex );
#endif
	ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
	ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
	ldap_pvt_thread_rdwr_destroy( &bdb->bi_idl_tree_rwlock );
	ldap_pvt_thread_mutex_destroy( &bdb->bi_idl_tree_lrulock );

	ch_free( bdb );
	be->be_private = NULL;

	return 0;
}
Exemplo n.º 8
0
void slap_op_destroy(void)
{
	Operation *o;

	while ( (o = LDAP_STAILQ_FIRST( &slap_free_ops )) != NULL) {
		LDAP_STAILQ_REMOVE_HEAD( &slap_free_ops, o_next );
		LDAP_STAILQ_NEXT(o, o_next) = NULL;
		ch_free( o );
	}
	ldap_pvt_thread_mutex_destroy( &slap_op_mutex );
}
Exemplo n.º 9
0
static int
wt_db_destroy( Backend *be, ConfigReply *cr )
{
	struct wt_info *wi = (struct wt_info *) be->be_private;

	if( wi->wi_dbenv_home ) {
		ch_free( wi->wi_dbenv_home );
		wi->wi_dbenv_home = NULL;
	}
	if( wi->wi_dbenv_config ) {
		ch_free( wi->wi_dbenv_config );
		wi->wi_dbenv_config = NULL;
	}

	wt_attr_index_destroy( wi );
	ch_free( wi );
	be->be_private = NULL;

	return LDAP_SUCCESS;
}
Exemplo n.º 10
0
void
wt_ctx_free( void *key, void *data )
{
	wt_ctx *wc = data;

	if(wc->session){
		wc->session->close(wc->session, NULL);
		wc->session = NULL;
	}
	ch_free(wc);
}
Exemplo n.º 11
0
int
perl_back_compare(
	Operation	*op,
	SlapReply	*rs )
{
	int count, avalen;
	char *avastr;

	PerlBackend *perl_back = (PerlBackend *)op->o_bd->be_private;

	avalen = op->orc_ava->aa_desc->ad_cname.bv_len + 1 +
		op->orc_ava->aa_value.bv_len;
	avastr = ch_malloc( avalen + 1 );

	lutil_strcopy( lutil_strcopy( lutil_strcopy( avastr,
		op->orc_ava->aa_desc->ad_cname.bv_val ), "=" ),
		op->orc_ava->aa_value.bv_val );

	PERL_SET_CONTEXT( PERL_INTERPRETER );
	ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );	

	{
		dSP; ENTER; SAVETMPS;

		PUSHMARK(sp);
		XPUSHs( perl_back->pb_obj_ref );
		XPUSHs(sv_2mortal(newSVpv( op->o_req_dn.bv_val , op->o_req_dn.bv_len)));
		XPUSHs(sv_2mortal(newSVpv( avastr , avalen)));
		PUTBACK;

		count = call_method("compare", G_SCALAR);

		SPAGAIN;

		if (count != 1) {
			croak("Big trouble in back_compare\n");
		}

		rs->sr_err = POPi;

		PUTBACK; FREETMPS; LEAVE;
	}

	ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );	

	ch_free( avastr );

	send_ldap_result( op, rs );

	Debug( LDAP_DEBUG_ANY, "Perl COMPARE\n", 0, 0, 0 );

	return (0);
}
Exemplo n.º 12
0
int
extops_kill (void)
{
	struct extop_list *ext;

	/* we allocated the memory, so we have to free it, too. */
	while ((ext = supp_ext_list) != NULL) {
		supp_ext_list = ext->next;
		ch_free(ext);
	}
	return(0);
}
Exemplo n.º 13
0
static int
valsort_destroy(
    BackendDB *be,
    ConfigReply *cr
)
{
    slap_overinst *on = (slap_overinst *)be->bd_info;
    valsort_info *vi = on->on_bi.bi_private, *next;

#ifdef SLAP_CONFIG_DELETE
    overlay_unregister_control( be, LDAP_CONTROL_VALSORT );
#endif /* SLAP_CONFIG_DELETE */

    for (; vi; vi = next) {
        next = vi->vi_next;
        ch_free( vi->vi_dn.bv_val );
        ch_free( vi );
    }

    return 0;
}
Exemplo n.º 14
0
static void
target_free(
	metatarget_t	*mt )
{
	if ( mt->mt_uri ) {
		free( mt->mt_uri );
		ldap_pvt_thread_mutex_destroy( &mt->mt_uri_mutex );
	}
	if ( mt->mt_subtree ) {
		meta_subtree_destroy( mt->mt_subtree );
		mt->mt_subtree = NULL;
	}
	if ( mt->mt_filter ) {
		meta_filter_destroy( mt->mt_filter );
		mt->mt_filter = NULL;
	}
	if ( !BER_BVISNULL( &mt->mt_psuffix ) ) {
		free( mt->mt_psuffix.bv_val );
	}
	if ( !BER_BVISNULL( &mt->mt_nsuffix ) ) {
		free( mt->mt_nsuffix.bv_val );
	}
	if ( !BER_BVISNULL( &mt->mt_binddn ) ) {
		free( mt->mt_binddn.bv_val );
	}
	if ( !BER_BVISNULL( &mt->mt_bindpw ) ) {
		free( mt->mt_bindpw.bv_val );
	}
	if ( !BER_BVISNULL( &mt->mt_idassert_authcID ) ) {
		ch_free( mt->mt_idassert_authcID.bv_val );
	}
	if ( !BER_BVISNULL( &mt->mt_idassert_authcDN ) ) {
		ch_free( mt->mt_idassert_authcDN.bv_val );
	}
	if ( !BER_BVISNULL( &mt->mt_idassert_passwd ) ) {
		ch_free( mt->mt_idassert_passwd.bv_val );
	}
	if ( !BER_BVISNULL( &mt->mt_idassert_authzID ) ) {
		ch_free( mt->mt_idassert_authzID.bv_val );
	}
	if ( !BER_BVISNULL( &mt->mt_idassert_sasl_mech ) ) {
		ch_free( mt->mt_idassert_sasl_mech.bv_val );
	}
	if ( !BER_BVISNULL( &mt->mt_idassert_sasl_realm ) ) {
		ch_free( mt->mt_idassert_sasl_realm.bv_val );
	}
	if ( mt->mt_idassert_authz != NULL ) {
		ber_bvarray_free( mt->mt_idassert_authz );
	}
	if ( mt->mt_rwmap.rwm_rw ) {
		rewrite_info_delete( &mt->mt_rwmap.rwm_rw );
		if ( mt->mt_rwmap.rwm_bva_rewrite )
			ber_bvarray_free( mt->mt_rwmap.rwm_bva_rewrite );
	}
	meta_back_map_free( &mt->mt_rwmap.rwm_oc );
	meta_back_map_free( &mt->mt_rwmap.rwm_at );
	ber_bvarray_free( mt->mt_rwmap.rwm_bva_map );

	free( mt );
}
Exemplo n.º 15
0
/*
 * releases the lock of the entry; if it is marked as volatile, it is
 * destroyed.
 */
int
monitor_cache_release(
	monitor_info_t	*mi,
	Entry		*e )
{
	monitor_entry_t *mp;

	assert( mi != NULL );
	assert( e != NULL );
	assert( e->e_private != NULL );
	
	mp = ( monitor_entry_t * )e->e_private;

	if ( mp->mp_flags & MONITOR_F_VOLATILE ) {
		monitor_cache_t	*mc, tmp_mc;

		/* volatile entries do not return to cache */
		ldap_pvt_thread_mutex_lock( &mi->mi_cache_mutex );
		tmp_mc.mc_ndn = e->e_nname;
		mc = avl_delete( &mi->mi_cache,
				( caddr_t )&tmp_mc, monitor_cache_cmp );
		ldap_pvt_thread_mutex_unlock( &mi->mi_cache_mutex );
		if ( mc != NULL ) {
			ch_free( mc );
		}
		
		ldap_pvt_thread_mutex_unlock( &mp->mp_mutex );
		ldap_pvt_thread_mutex_destroy( &mp->mp_mutex );
		ch_free( mp );
		e->e_private = NULL;
		entry_free( e );

		return( 0 );
	}
	
	ldap_pvt_thread_mutex_unlock( &mp->mp_mutex );

	return( 0 );
}
Exemplo n.º 16
0
void
ldap_back_conn_free( void *v_lc )
{
	ldapconn_t	*lc = v_lc;

	if ( lc->lc_ld != NULL ) {	
		ldap_unbind_ext( lc->lc_ld, NULL, NULL );
	}
	if ( !BER_BVISNULL( &lc->lc_bound_ndn ) ) {
		ch_free( lc->lc_bound_ndn.bv_val );
	}
	if ( !BER_BVISNULL( &lc->lc_cred ) ) {
		memset( lc->lc_cred.bv_val, 0, lc->lc_cred.bv_len );
		ch_free( lc->lc_cred.bv_val );
	}
	if ( !BER_BVISNULL( &lc->lc_local_ndn ) ) {
		ch_free( lc->lc_local_ndn.bv_val );
	}
	lc->lc_q.tqe_prev = NULL;
	lc->lc_q.tqe_next = NULL;
	ch_free( lc );
}
Exemplo n.º 17
0
void slapd_slp_init( const char* urls ) {
	int i;

	slapd_srvurls = ldap_str2charray( urls, " " );

	if( slapd_srvurls == NULL ) return;

	/* find and expand INADDR_ANY URLs */
	for( i=0; slapd_srvurls[i] != NULL; i++ ) {
		if( strcmp( slapd_srvurls[i], "ldap:///" ) == 0) {
			char *host = ldap_pvt_get_fqdn( NULL );
			if ( host != NULL ) {
				slapd_srvurls[i] = (char *) ch_realloc( slapd_srvurls[i],
					strlen( host ) +
					sizeof( LDAP_SRVTYPE_PREFIX ) );
				strcpy( lutil_strcopy(slapd_srvurls[i],
					LDAP_SRVTYPE_PREFIX ), host );

				ch_free( host );
			}

		} else if ( strcmp( slapd_srvurls[i], "ldaps:///" ) == 0) {
			char *host = ldap_pvt_get_fqdn( NULL );
			if ( host != NULL ) {
				slapd_srvurls[i] = (char *) ch_realloc( slapd_srvurls[i],
					strlen( host ) +
					sizeof( LDAPS_SRVTYPE_PREFIX ) );
				strcpy( lutil_strcopy(slapd_srvurls[i],
					LDAPS_SRVTYPE_PREFIX ), host );

				ch_free( host );
			}
		}
	}

	/* open the SLP handle */
	SLPOpen( "en", 0, &slapd_hslp );
}
Exemplo n.º 18
0
static int
usn_db_destroy(
	BackendDB *be,
	ConfigReply *cr
)
{
	slap_overinst	*on = (slap_overinst *)be->bd_info;
	usn_info_t	*ui = on->on_bi.bi_private;

	ldap_pvt_thread_mutex_destroy( &ui->ui_mutex );
	ch_free( ui );
	on->on_bi.bi_private = NULL;
	return 0;
}
Exemplo n.º 19
0
static int
denyop_destroy(
	BackendDB *be
)
{
	slap_overinst	*on = (slap_overinst *) be->bd_info;
	denyop_info	*oi = (denyop_info *)on->on_bi.bi_private;

	if ( oi ) {
		ch_free( oi );
	}

	return 0;
}
Exemplo n.º 20
0
int
unload_extop(
	const struct berval *ext_oid,
	SLAP_EXTOP_MAIN_FN *ext_main,
	unsigned flags )
{
	struct berval		oidm = BER_BVNULL;
	struct extop_list	*ext, **extp;

	/* oid must be given */
	if ( ext_oid == NULL || BER_BVISNULL( ext_oid ) ||
		BER_BVISEMPTY( ext_oid ) )
	{
		return -1; 
	}

	/* if it's not an oid, check if it's a macto */
	if ( numericoidValidate( NULL, (struct berval *)ext_oid ) !=
		LDAP_SUCCESS )
	{
		oidm.bv_val = oidm_find( ext_oid->bv_val );
		if ( oidm.bv_val == NULL ) {
			return -1;
		}
		oidm.bv_len = strlen( oidm.bv_val );
		ext_oid = &oidm;
	}

	/* lookup the oid */
	for ( extp = &supp_ext_list; *extp; extp = &(*extp)->next ) {
		if ( bvmatch( ext_oid, &(*extp)->oid ) ) {
			/* if ext_main is given, only remove if it matches */
			if ( ext_main != NULL && (*extp)->ext_main != ext_main ) {
				return -1;
			}
			break;
		}
	}

	if ( *extp == NULL ) {
		return -1;
	}

	ext = *extp;
	*extp = (*extp)->next;

	ch_free( ext );

	return 0;
}
Exemplo n.º 21
0
static void
monitor_entry_destroy( void *v_mc )
{
	monitor_cache_t		*mc = (monitor_cache_t *)v_mc;

	if ( mc->mc_e != NULL ) {
		monitor_entry_t *mp;

		assert( mc->mc_e->e_private != NULL );
	
		mp = ( monitor_entry_t * )mc->mc_e->e_private;

		if ( mp->mp_cb ) {
			monitor_callback_t	*cb;

			for ( cb = mp->mp_cb; cb != NULL; ) {
				monitor_callback_t	*next = cb->mc_next;

				if ( cb->mc_free ) {
					(void)cb->mc_free( mc->mc_e, &cb->mc_private );
				}
				ch_free( mp->mp_cb );

				cb = next;
			}
		}

		ldap_pvt_thread_mutex_destroy( &mp->mp_mutex );

		ch_free( mp );
		mc->mc_e->e_private = NULL;
		entry_free( mc->mc_e );
	}

	ch_free( mc );
}
Exemplo n.º 22
0
static int
vernum_db_destroy(
	BackendDB	*be,
	ConfigReply	*cr )
{
	slap_overinst *on = (slap_overinst *)be->bd_info;
	vernum_t *vn = (vernum_t *)on->on_bi.bi_private;

	if ( vn ) {
		ch_free( vn );
		on->on_bi.bi_private = NULL;
	}

	return 0;
}
Exemplo n.º 23
0
static int
pg_dynacl_destroy(
	void		*priv )
{
	pg_t		*pg = (pg_t *)priv;

	if ( pg != NULL ) {
		if ( !BER_BVISNULL( &pg->pg_pat ) ) {
			ber_memfree( pg->pg_pat.bv_val );
		}
		ch_free( pg );
	}

	return 0;
}
Exemplo n.º 24
0
static int
adremap_db_destroy(
	BackendDB *be,
	ConfigReply *cr
)
{
	slap_overinst *on = (slap_overinst *) be->bd_info;
	adremap_info *ai = (adremap_info *) on->on_bi.bi_private;
	adremap_case *ac;
	adremap_dnv *ad;

	/* free config */
	for (ac = ai->ai_case; ac; ac = ai->ai_case) {
		ai->ai_case = ac->ac_next;
		ch_free(ac);
	}
	for (ad = ai->ai_dnv; ad; ad = ai->ai_dnv) {
		ai->ai_dnv = ad->ad_next;
		ch_free(ad);
	}
	free( ai );

	return 0;
}
Exemplo n.º 25
0
/*
 * metaconn_free
 *
 * clears a metaconn
 */
static void
metaconn_free(
		struct metaconn *lc
)
{
	if ( !lc ) {
		return;
	}
	
	if ( lc->conns ) {
		ch_free( lc->conns );
	}

	free( lc );
}
Exemplo n.º 26
0
static int
dyngroup_close(
	BackendDB *be,
	ConfigReply *cr
)
{
	slap_overinst *on = (slap_overinst *) be->bd_info;
	adpair *ap, *a2;

	for ( ap = on->on_bi.bi_private; ap; ap = a2 ) {
		a2 = ap->ap_next;
		ch_free( ap );
	}
	return 0;
}
Exemplo n.º 27
0
static int
monitor_subsys_sent_destroy(
	BackendDB		*be,
	monitor_subsys_t	*ms )
{
	int		i;

	for ( i = 0; i < MONITOR_SENT_LAST; i++ ) {
		if ( !BER_BVISNULL( &monitor_sent[ i ].nrdn ) ) {
			ch_free( monitor_sent[ i ].nrdn.bv_val );
		}
	}

	return 0;
}
Exemplo n.º 28
0
static int
mdb_db_close( BackendDB *be, ConfigReply *cr )
{
	int rc;
	struct mdb_info *mdb = (struct mdb_info *) be->be_private;

	/* monitor handling */
	(void)mdb_monitor_db_close( be );

	mdb->mi_flags &= ~MDB_IS_OPEN;

	if( mdb->mi_dbenv ) {
		mdb_reader_flush( mdb->mi_dbenv );
	}

	if ( mdb->mi_dbenv ) {
		if ( mdb->mi_dbis[0] ) {
			int i;

			mdb_attr_dbs_close( mdb );
			for ( i=0; i<MDB_NDB; i++ )
				mdb_dbi_close( mdb->mi_dbenv, mdb->mi_dbis[i] );

			/* force a sync, but not if we were ReadOnly,
			 * and not in Quick mode.
			 */
			if (!(slapMode & (SLAP_TOOL_QUICK|SLAP_TOOL_READONLY))) {
				rc = mdb_env_sync( mdb->mi_dbenv, 1 );
				if( rc != 0 ) {
					Debug( LDAP_DEBUG_ANY,
						"mdb_db_close: database \"%s\": "
						"mdb_env_sync failed: %s (%d).\n",
						be->be_suffix[0].bv_val, mdb_strerror(rc), rc );
				}
			}
		}

		mdb_env_close( mdb->mi_dbenv );
		mdb->mi_dbenv = NULL;
	}

	if ( mdb->mi_search_stack ) {
		ch_free( mdb->mi_search_stack );
		mdb->mi_search_stack = NULL;
	}

	return 0;
}
Exemplo n.º 29
0
static int
retcode_cleanup_cb( Operation *op, SlapReply *rs )
{
	rs->sr_matched = NULL;
	rs->sr_text = NULL;

	if ( rs->sr_ref != NULL ) {
		ber_bvarray_free( rs->sr_ref );
		rs->sr_ref = NULL;
	}

	ch_free( op->o_callback );
	op->o_callback = NULL;

	return SLAP_CB_CONTINUE;
}
Exemplo n.º 30
0
void
limits_destroy( 
	struct slap_limits	**lm )
{
	int		i;

	if ( lm == NULL ) {
		return;
	}

	for ( i = 0; lm[ i ]; i++ ) {
		limits_free_one( lm[ i ] );
	}

	ch_free( lm );
}