]> git.sur5r.net Git - openldap/commitdiff
ITS#6981 pcache: don't reference rs->sr_entry in op_cleanup
authorHoward Chu <hyc@openldap.org>
Wed, 2 Nov 2011 16:26:50 +0000 (09:26 -0700)
committerHoward Chu <hyc@openldap.org>
Wed, 2 Nov 2011 16:26:50 +0000 (09:26 -0700)
servers/slapd/overlays/pcache.c

index d27dcb7a0a7e176279f2e84aef65f980d8aec045..2af2f068407513f2acb344b5d07cc77705decdb4 100644 (file)
@@ -2343,62 +2343,6 @@ pcache_op_cleanup( Operation *op, SlapReply *rs ) {
        cache_manager *cm = on->on_bi.bi_private;
        query_manager*          qm = cm->qm;
 
-       if ( rs->sr_type == REP_SEARCH ) {
-               Entry *e;
-
-               /* don't return more entries than requested by the client */
-               if ( si->slimit > 0 && rs->sr_nentries >= si->slimit ) {
-                       si->slimit_exceeded = 1;
-               }
-
-               /* If we haven't exceeded the limit for this query,
-                * build a chain of answers to store. If we hit the
-                * limit, empty the chain and ignore the rest.
-                */
-               if ( !si->over ) {
-                       /* check if the entry contains undefined
-                        * attributes/objectClasses (ITS#5680) */
-                       if ( cm->check_cacheability && test_filter( op, rs->sr_entry, si->query.filter ) != LDAP_COMPARE_TRUE ) {
-                               Debug( pcache_debug, "%s: query not cacheable because of schema issues in DN \"%s\"\n",
-                                       op->o_log_prefix, rs->sr_entry->e_name.bv_val, 0 );
-                               goto over;
-                       }
-
-                       /* check for malformed entries: attrs with no values */
-                       {
-                               Attribute *a = rs->sr_entry->e_attrs;
-                               for (; a; a=a->a_next) {
-                                       if ( !a->a_numvals ) {
-                                               Debug( pcache_debug, "%s: query not cacheable because of attrs without values in DN \"%s\" (%s)\n",
-                                               op->o_log_prefix, rs->sr_entry->e_name.bv_val,
-                                               a->a_desc->ad_cname.bv_val );
-                                               goto over;
-                                       }
-                               }
-                       }
-
-                       if ( si->count < si->max ) {
-                               si->count++;
-                               e = entry_dup( rs->sr_entry );
-                               if ( !si->head ) si->head = e;
-                               if ( si->tail ) si->tail->e_private = e;
-                               si->tail = e;
-
-                       } else {
-over:;
-                               si->over = 1;
-                               si->count = 0;
-                               for (;si->head; si->head=e) {
-                                       e = si->head->e_private;
-                                       si->head->e_private = NULL;
-                                       entry_free(si->head);
-                               }
-                               si->tail = NULL;
-                       }
-               }
-
-       }
-
        if ( rs->sr_type == REP_RESULT || 
                op->o_abandon || rs->sr_err == SLAPD_ABANDON )
        {
@@ -2498,11 +2442,64 @@ pcache_response(
        }
 
        if ( rs->sr_type == REP_SEARCH ) {
+               Entry *e;
+
                /* don't return more entries than requested by the client */
+               if ( si->slimit > 0 && rs->sr_nentries >= si->slimit ) {
+                       si->slimit_exceeded = 1;
+               }
                if ( si->slimit_exceeded ) {
                        return 0;
                }
 
+               /* If we haven't exceeded the limit for this query,
+                * build a chain of answers to store. If we hit the
+                * limit, empty the chain and ignore the rest.
+                */
+               if ( !si->over ) {
+                       slap_overinst *on = si->on;
+                       cache_manager *cm = on->on_bi.bi_private;
+
+                       /* check if the entry contains undefined
+                        * attributes/objectClasses (ITS#5680) */
+                       if ( cm->check_cacheability && test_filter( op, rs->sr_entry, si->query.filter ) != LDAP_COMPARE_TRUE ) {
+                               Debug( pcache_debug, "%s: query not cacheable because of schema issues in DN \"%s\"\n",
+                                       op->o_log_prefix, rs->sr_entry->e_name.bv_val, 0 );
+                               goto over;
+                       }
+
+                       /* check for malformed entries: attrs with no values */
+                       {
+                               Attribute *a = rs->sr_entry->e_attrs;
+                               for (; a; a=a->a_next) {
+                                       if ( !a->a_numvals ) {
+                                               Debug( pcache_debug, "%s: query not cacheable because of attrs without values in DN \"%s\" (%s)\n",
+                                               op->o_log_prefix, rs->sr_entry->e_name.bv_val,
+                                               a->a_desc->ad_cname.bv_val );
+                                               goto over;
+                                       }
+                               }
+                       }
+
+                       if ( si->count < si->max ) {
+                               si->count++;
+                               e = entry_dup( rs->sr_entry );
+                               if ( !si->head ) si->head = e;
+                               if ( si->tail ) si->tail->e_private = e;
+                               si->tail = e;
+
+                       } else {
+over:;
+                               si->over = 1;
+                               si->count = 0;
+                               for (;si->head; si->head=e) {
+                                       e = si->head->e_private;
+                                       si->head->e_private = NULL;
+                                       entry_free(si->head);
+                               }
+                               si->tail = NULL;
+                       }
+               }
        } else if ( rs->sr_type == REP_RESULT ) {
 
                if ( si->count ) {