Esempio n. 1
0
int
ldap_back_db_destroy( Backend *be, ConfigReply *cr )
{
	if ( be->be_private ) {
		ldapinfo_t	*li = ( ldapinfo_t * )be->be_private;
		unsigned	i;

		(void)ldap_back_monitor_db_destroy( be );

		ldap_pvt_thread_mutex_lock( &li->li_conninfo.lai_mutex );

		if ( li->li_uri != NULL ) {
			ch_free( li->li_uri );
			li->li_uri = NULL;

			assert( li->li_bvuri != NULL );
			ber_bvarray_free( li->li_bvuri );
			li->li_bvuri = NULL;
		}

		bindconf_free( &li->li_tls );
		bindconf_free( &li->li_acl );
		bindconf_free( &li->li_idassert.si_bc );

		if ( li->li_idassert_authz != NULL ) {
			ber_bvarray_free( li->li_idassert_authz );
			li->li_idassert_authz = NULL;
		}
               	if ( li->li_conninfo.lai_tree ) {
			avl_free( li->li_conninfo.lai_tree, ldap_back_conn_free );
		}
		for ( i = LDAP_BACK_PCONN_FIRST; i < LDAP_BACK_PCONN_LAST; i++ ) {
			while ( !LDAP_TAILQ_EMPTY( &li->li_conn_priv[ i ].lic_priv ) ) {
				ldapconn_t	*lc = LDAP_TAILQ_FIRST( &li->li_conn_priv[ i ].lic_priv );

				LDAP_TAILQ_REMOVE( &li->li_conn_priv[ i ].lic_priv, lc, lc_q );
				ldap_back_conn_free( lc );
			}
		}
		if ( LDAP_BACK_QUARANTINE( li ) ) {
			slap_retry_info_destroy( &li->li_quarantine );
			ldap_pvt_thread_mutex_destroy( &li->li_quarantine_mutex );
		}

		ldap_pvt_thread_mutex_unlock( &li->li_conninfo.lai_mutex );
		ldap_pvt_thread_mutex_destroy( &li->li_conninfo.lai_mutex );
		ldap_pvt_thread_mutex_destroy( &li->li_uri_mutex );

		for ( i = 0; i < SLAP_OP_LAST; i++ ) {
			ldap_pvt_mp_clear( li->li_ops_completed[ i ] );
		}
		ldap_pvt_thread_mutex_destroy( &li->li_counter_mutex );
	}

	ch_free( be->be_private );

	return 0;
}
Esempio n. 2
0
void slap_counters_destroy( slap_counters_t *sc )
{
	int i;

	ldap_pvt_thread_mutex_destroy( &sc->sc_mutex );
	ldap_pvt_mp_clear( sc->sc_bytes );
	ldap_pvt_mp_clear( sc->sc_pdu );
	ldap_pvt_mp_clear( sc->sc_entries );
	ldap_pvt_mp_clear( sc->sc_refs );

	ldap_pvt_mp_clear( sc->sc_ops_initiated );
	ldap_pvt_mp_clear( sc->sc_ops_completed );

#ifdef SLAPD_MONITOR
	for ( i = 0; i < SLAP_OP_LAST; i++ ) {
		ldap_pvt_mp_clear( sc->sc_ops_initiated_[ i ] );
		ldap_pvt_mp_clear( sc->sc_ops_completed_[ i ] );
	}
#endif /* SLAPD_MONITOR */
}
Esempio n. 3
0
static int
monitor_subsys_sent_update(
	Operation		*op,
	SlapReply		*rs,
	Entry                   *e )
{
	monitor_info_t	*mi = ( monitor_info_t *)op->o_bd->be_private;
	
	struct berval		nrdn;
	ldap_pvt_mp_t		n;
	Attribute		*a;
	slap_counters_t *sc;
	int			i;

	assert( mi != NULL );
	assert( e != NULL );

	dnRdn( &e->e_nname, &nrdn );

	for ( i = 0; i < MONITOR_SENT_LAST; i++ ) {
		if ( dn_match( &nrdn, &monitor_sent[ i ].nrdn ) ) {
			break;
		}
	}

	if ( i == MONITOR_SENT_LAST ) {
		return SLAP_CB_CONTINUE;
	}

	ldap_pvt_thread_mutex_lock(&slap_counters.sc_mutex);
	switch ( i ) {
	case MONITOR_SENT_ENTRIES:
		ldap_pvt_mp_init_set( n, slap_counters.sc_entries );
		for ( sc = slap_counters.sc_next; sc; sc = sc->sc_next ) {
			ldap_pvt_thread_mutex_lock( &sc->sc_mutex );
			ldap_pvt_mp_add( n, sc->sc_entries );
			ldap_pvt_thread_mutex_unlock( &sc->sc_mutex );
		}
		break;

	case MONITOR_SENT_REFERRALS:
		ldap_pvt_mp_init_set( n, slap_counters.sc_refs );
		for ( sc = slap_counters.sc_next; sc; sc = sc->sc_next ) {
			ldap_pvt_thread_mutex_lock( &sc->sc_mutex );
			ldap_pvt_mp_add( n, sc->sc_refs );
			ldap_pvt_thread_mutex_unlock( &sc->sc_mutex );
		}
		break;

	case MONITOR_SENT_PDU:
		ldap_pvt_mp_init_set( n, slap_counters.sc_pdu );
		for ( sc = slap_counters.sc_next; sc; sc = sc->sc_next ) {
			ldap_pvt_thread_mutex_lock( &sc->sc_mutex );
			ldap_pvt_mp_add( n, sc->sc_pdu );
			ldap_pvt_thread_mutex_unlock( &sc->sc_mutex );
		}
		break;

	case MONITOR_SENT_BYTES:
		ldap_pvt_mp_init_set( n, slap_counters.sc_bytes );
		for ( sc = slap_counters.sc_next; sc; sc = sc->sc_next ) {
			ldap_pvt_thread_mutex_lock( &sc->sc_mutex );
			ldap_pvt_mp_add( n, sc->sc_bytes );
			ldap_pvt_thread_mutex_unlock( &sc->sc_mutex );
		}
		break;

	default:
		assert(0);
	}
	ldap_pvt_thread_mutex_unlock(&slap_counters.sc_mutex);
	
	a = attr_find( e->e_attrs, mi->mi_ad_monitorCounter );
	assert( a != NULL );

	/* NOTE: no minus sign is allowed in the counters... */
	UI2BV( &a->a_vals[ 0 ], n );
	ldap_pvt_mp_clear( n );

	/* FIXME: touch modifyTimestamp? */

	return SLAP_CB_CONTINUE;
}