- 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;
- }
- }
-
- }
-