From c67026495147468a0ae9222c0ad1ffc21126f5b1 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 17 Aug 2009 22:24:26 +0000 Subject: [PATCH] For refresh_purge, only delete entry if ours is the last queryid on it. Otherwise just remove our queryid. --- servers/slapd/overlays/pcache.c | 36 +++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c index bcaf7ac1b7..94aed0c121 100644 --- a/servers/slapd/overlays/pcache.c +++ b/servers/slapd/overlays/pcache.c @@ -2673,6 +2673,7 @@ get_attr_set( typedef struct dnlist { struct dnlist *next; struct berval dn; + char delete; } dnlist; typedef struct refresh_info { @@ -2794,9 +2795,13 @@ refresh_purge( Operation *op, SlapReply *rs ) } /* No, so put it on the list to delete */ if ( del ) { + Attribute *a; dnlist *dnl = dnl_alloc( op, &rs->sr_entry->e_nname ); dnl->next = ri->ri_dels; ri->ri_dels = dnl; + a = attr_find( rs->sr_entry->e_attrs, ad_queryId ); + /* If ours is the only queryId, delete entry */ + dnl->delete = ( a->a_numvals == 1 ); } } return 0; @@ -2811,6 +2816,7 @@ refresh_query( Operation *op, SlapReply *rs, CachedQuery *query, char filter_str[ LDAP_LUTIL_UUIDSTR_BUFSIZE + STRLENOF( "(queryId=)" ) ]; AttributeAssertion ava = ATTRIBUTEASSERTION_INIT; Filter filter = {LDAP_FILTER_EQUALITY}; + AttributeName attrs[ 2 ] = {{{ 0 }}}; dnlist *dn; int i, rc; @@ -2860,18 +2866,40 @@ refresh_query( Operation *op, SlapReply *rs, CachedQuery *query, filter.f_ava = &ava; filter.f_av_desc = ad_queryId; filter.f_av_value = query->q_uuid; - op->ors_attrs = slap_anlist_no_attrs; - op->ors_attrsonly = 1; + attrs[ 0 ].an_desc = ad_queryId; + attrs[ 0 ].an_name = ad_queryId->ad_cname; + op->ors_attrs = attrs; + op->ors_attrsonly = 0; rs->sr_entry = NULL; rs->sr_nentries = 0; rc = op->o_bd->be_search( op, rs ); if ( rc ) goto leave; - op->o_tag = LDAP_REQ_DELETE; while (( dn = ri.ri_dels )) { op->o_req_dn = dn->dn; op->o_req_ndn = dn->dn; - op->o_bd->be_delete( op, rs ); + if ( dn->delete ) { + op->o_tag = LDAP_REQ_DELETE; + op->o_bd->be_delete( op, rs ); + } else { + Modifications mod; + struct berval vals[2]; + + vals[0] = query->q_uuid; + BER_BVZERO( &vals[1] ); + mod.sml_op = LDAP_MOD_DELETE; + mod.sml_flags = 0; + mod.sml_desc = ad_queryId; + mod.sml_type = ad_queryId->ad_cname; + mod.sml_values = vals; + mod.sml_nvalues = NULL; + mod.sml_numvals = 1; + mod.sml_next = NULL; + + op->o_tag = LDAP_REQ_MODIFY; + op->orm_modlist = &mod; + op->o_bd->be_modify( op, rs ); + } ri.ri_dels = dn->next; op->o_tmpfree( dn, op->o_tmpmemctx ); } -- 2.39.5