]> git.sur5r.net Git - openldap/commitdiff
update cachedQueryURL only when requested
authorPierangelo Masarati <ando@openldap.org>
Tue, 18 Aug 2009 08:38:42 +0000 (08:38 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 18 Aug 2009 08:38:42 +0000 (08:38 +0000)
servers/slapd/overlays/pcache.c

index 76cd1037ddc3150fe36babb4e3cb46063b55b031..5601ede5711056119fa0fe749f13e0a4b7c0b0dc 100644 (file)
@@ -2876,7 +2876,7 @@ refresh_query( Operation *op, SlapReply *rs, CachedQuery *query,
        Filter filter = {LDAP_FILTER_EQUALITY};
        AttributeName attrs[ 2 ] = {{{ 0 }}};
        dnlist *dn;
-       int i, rc;
+       int rc;
 
        ldap_pvt_thread_mutex_lock( &query->answerable_cnt_mutex );
        query->refcnt = 0;
@@ -4563,10 +4563,12 @@ pcache_monitor_update(
        CachedQuery     *qc;
        BerVarray       vals = NULL;
 
-       Attribute       *a;
-       int             num = 0;
+       assert( ad_cachedQueryURL != NULL );
 
-       if ( qm->templates != NULL ) {
+       attr_delete( &e->e_attrs, ad_cachedQueryURL );
+       if ( ( SLAP_OPATTRS( rs->sr_attr_flags ) || ad_inlist( ad_cachedQueryURL, rs->sr_attrs ) )
+               && qm->templates != NULL )
+       {
                QueryTemplate *tm;
 
                for ( tm = qm->templates; tm != NULL; tm = tm->qmnext ) {
@@ -4575,22 +4577,17 @@ pcache_monitor_update(
 
                                if ( query2url( op, qc, &bv, 1 ) == 0 ) {
                                        ber_bvarray_add_x( &vals, &bv, op->o_tmpmemctx );
-                                       num++;
                                }
                        }
                }
-       }
 
-       assert( ad_cachedQueryURL != NULL );
 
-       attr_delete( &e->e_attrs, ad_cachedQueryURL );
-       if ( vals == NULL ) {
-               return SLAP_CB_CONTINUE;
+               if ( vals != NULL ) {
+                       attr_merge_normalize( e, ad_cachedQueryURL, vals, NULL );
+                       ber_bvarray_free_x( vals, op->o_tmpmemctx );
+               }
        }
 
-       attr_merge_normalize( e, ad_cachedQueryURL, vals, NULL );
-       ber_bvarray_free_x( vals, op->o_tmpmemctx );
-
        return SLAP_CB_CONTINUE;
 }