From 1a349907f34a6ac86a8ed43d734447ee25c93a8d Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Fri, 28 Dec 2001 15:58:51 +0000 Subject: [PATCH] cached entries are deleted if volatile; small improvements --- servers/slapd/back-monitor/cache.c | 27 +++++++++++++++++++++++---- servers/slapd/back-monitor/conn.c | 18 ++++++++++++++---- servers/slapd/back-monitor/log.c | 23 ++--------------------- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/servers/slapd/back-monitor/cache.c b/servers/slapd/back-monitor/cache.c index 6f8c4b82e6..0281564db0 100644 --- a/servers/slapd/back-monitor/cache.c +++ b/servers/slapd/back-monitor/cache.c @@ -74,13 +74,18 @@ monitor_cache_dup( struct monitorcache *cc1 = ( struct monitorcache * )c1; struct monitorcache *cc2 = ( struct monitorcache * )c2; - int d = cc1->mc_ndn->bv_len - cc2->mc_ndn->bv_len; - int cmp; /* * case sensitive, because the dn MUST be normalized */ - cmp = d != 0 ? d : strcmp( cc1->mc_ndn->bv_val, cc2->mc_ndn->bv_val ); +#if 0 + int cmp = monitor_cache_cmp( c1, c2 ); +#else + int d = cc1->mc_ndn->bv_len - cc2->mc_ndn->bv_len; + int cmp = + d != 0 ? d : strcmp( cc1->mc_ndn->bv_val, cc2->mc_ndn->bv_val ); +#endif + return cmp == 0 ? -1 : 0; } @@ -203,16 +208,19 @@ monitor_cache_dn2entry( } /* try with parent/ancestors */ - if ( ndn && ndn->bv_len ) { + if ( ndn->bv_len ) { p_ndn.bv_val = dn_parent( NULL, ndn->bv_val ); } + if ( p_ndn.bv_val == NULL ) { p_ndn.bv_val = ""; p_ndn.bv_len = 0; + } else { p_ndn.bv_len = ndn->bv_len - ( ber_len_t ) ( p_ndn.bv_val - ndn->bv_val ); } + rc = monitor_cache_dn2entry( mi, &p_ndn, &e_parent, matched ); if ( rc || e_parent == NULL) { return( -1 ); @@ -253,15 +261,26 @@ monitor_cache_release( mp = ( struct monitorentrypriv * )e->e_private; if ( mp->mp_flags & MONITOR_F_VOLATILE ) { + struct monitorcache *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 ); + ch_free( mc ); + 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 ); } diff --git a/servers/slapd/back-monitor/conn.c b/servers/slapd/back-monitor/conn.c index 3372bf1355..123b8bb915 100644 --- a/servers/slapd/back-monitor/conn.c +++ b/servers/slapd/back-monitor/conn.c @@ -399,22 +399,32 @@ monitor_subsys_conn_create( *ep = e; } else { - char **values; - struct berval rdn; + char **values = NULL; unsigned long connid; /* create exactly the required entry */ +#if 0 + struct berval rdn; + + /* + * FIXME: we can pass the entire DN + * only if rdn_attrs does not complain. + */ if ( dnExtractRdn( ndn, &rdn ) != LDAP_SUCCESS ) { return( -1 ); } - if ( rdn_attrs( rdn.bv_val, NULL, &values ) != LDAP_SUCCESS ) { free( rdn.bv_val ); return( -1 ); } free( rdn.bv_val ); - +#else + if ( rdn_attrs( ndn->bv_val, NULL, &values ) != LDAP_SUCCESS ) { + return( -1 ); + } +#endif + assert( values ); assert( values[ 0 ] ); diff --git a/servers/slapd/back-monitor/log.c b/servers/slapd/back-monitor/log.c index 902fae1b14..73d8a8e87f 100644 --- a/servers/slapd/back-monitor/log.c +++ b/servers/slapd/back-monitor/log.c @@ -148,26 +148,8 @@ monitor_subsys_log_modify( Modification *mod = &ml->sml_mod; /* - * Operational attributes + * accept all operational attributes */ -#if 0 - if ( mod->sm_desc == slap_schema.si_ad_modifyTimestamp - || mod->sm_desc == slap_schema.si_ad_modifiersName ) { - ( void ) attr_delete( &e->e_attrs, mod->sm_desc ); - rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues ); - if ( rc != 0 ) { - rc = LDAP_OTHER; - break; - } - continue; - - /* - * unhandled operational attributes - */ - } else if ( is_at_operational( mod->sm_desc->ad_type ) ) { - continue; - -#else if ( is_at_operational( mod->sm_desc->ad_type ) ) { ( void ) attr_delete( &e->e_attrs, mod->sm_desc ); rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues ); @@ -177,7 +159,6 @@ monitor_subsys_log_modify( } continue; -#endif /* * only the monitor description attribute can be modified */ @@ -234,7 +215,7 @@ monitor_subsys_log_modify( ldap_syslog = newlevel; -#if 0 +#if 0 /* debug rather than log */ slap_debug = newlevel; lutil_set_debug_level( "slapd", slap_debug ); ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &slap_debug); -- 2.39.5