]> git.sur5r.net Git - openldap/commitdiff
cached entries are deleted if volatile; small improvements
authorPierangelo Masarati <ando@openldap.org>
Fri, 28 Dec 2001 15:58:51 +0000 (15:58 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 28 Dec 2001 15:58:51 +0000 (15:58 +0000)
servers/slapd/back-monitor/cache.c
servers/slapd/back-monitor/conn.c
servers/slapd/back-monitor/log.c

index 6f8c4b82e6c4e1823709e0711e72407c1a424f37..0281564db01a63f63c0f25a9fd0b0cb3aeb2a998 100644 (file)
@@ -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 );
 }
 
index 3372bf135528e3a2c37d578f700a8f42b9c02b64..123b8bb91532fe0cd9fa1382f8cf8cacb8d29839 100644 (file)
@@ -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 ] );
 
index 902fae1b1442f03b70358550d2a9e86dfd38d294..73d8a8e87f225d21a60d3a06399a0587dbe13817 100644 (file)
@@ -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);