From: Quanah Gibson-Mount Date: Wed, 10 Sep 2008 04:21:29 +0000 (+0000) Subject: ITS#5694 X-Git-Tag: OPENLDAP_REL_ENG_2_4_12~45 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a66330001bef33693fdcec03b2df49e872c36a92;p=openldap ITS#5694 --- diff --git a/CHANGES b/CHANGES index ebab0b44fa..b78919f198 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,7 @@ OpenLDAP 2.4.12 Engineering Fixed slapd-relay initialization (ITS#5643) Fixed slapd-sql freeing of connection (ITS#5607) Fixed slapd-sql fault on NULL fields (ITS#5653) + Fixed slapo-accesslog entryCSN generation on purge (ITS#5694) Fixed slapo-constraint string termination (ITS#5609) Fixed slapo-memberof internal operations DN (ITS#5622) Fixed slapo-pcache attrset crash (ITS#5665) diff --git a/servers/slapd/overlays/accesslog.c b/servers/slapd/overlays/accesslog.c index 5eee81b627..866afd7937 100644 --- a/servers/slapd/overlays/accesslog.c +++ b/servers/slapd/overlays/accesslog.c @@ -568,19 +568,22 @@ static int log_old_lookup( Operation *op, SlapReply *rs ) { purge_data *pd = op->o_callback->sc_private; + Attribute *a; if ( rs->sr_type != REP_SEARCH) return 0; if ( slapd_shutdown ) return 0; - /* Remember old CSN */ - if ( pd->csn.bv_val[0] == '\0' ) { - Attribute *a = attr_find( rs->sr_entry->e_attrs, - slap_schema.si_ad_entryCSN ); - if ( a ) { - int len = a->a_vals[0].bv_len; - if ( len > pd->csn.bv_len ) - len = pd->csn.bv_len; + /* Remember max CSN: should always be the last entry + * seen, since log entries are ordered chronologically... + */ + a = attr_find( rs->sr_entry->e_attrs, + slap_schema.si_ad_entryCSN ); + if ( a ) { + int len = a->a_vals[0].bv_len; + if ( len > pd->csn.bv_len ) + len = pd->csn.bv_len; + if ( memcmp( a->a_vals[0].bv_val, pd->csn.bv_val, len ) > 0 ) { AC_MEMCPY( pd->csn.bv_val, a->a_vals[0].bv_val, len ); pd->csn.bv_len = len; } @@ -656,6 +659,7 @@ accesslog_purge( void *ctx, void *arg ) if ( pd.used ) { int i; + /* delete the expired entries */ op->o_tag = LDAP_REQ_DELETE; op->o_callback = &nullsc; op->o_csn = pd.csn; @@ -670,6 +674,33 @@ accesslog_purge( void *ctx, void *arg ) } ch_free( pd.ndn ); ch_free( pd.dn ); + + { + Modifications mod; + struct berval bv[2]; + /* update context's entryCSN to reflect oldest CSN */ + mod.sml_numvals = 1; + mod.sml_values = bv; + bv[0] = pd.csn; + BER_BVZERO(&bv[1]); + mod.sml_nvalues = NULL; + mod.sml_desc = slap_schema.si_ad_entryCSN; + mod.sml_op = LDAP_MOD_REPLACE; + mod.sml_flags = SLAP_MOD_INTERNAL; + mod.sml_next = NULL; + + op->o_tag = LDAP_REQ_MODIFY; + op->orm_modlist = &mod; + op->orm_no_opattrs = 1; + op->o_req_dn = li->li_db->be_suffix[0]; + op->o_req_ndn = li->li_db->be_nsuffix[0]; + op->o_no_schema_check = 1; + op->o_managedsait = SLAP_CONTROL_NONCRITICAL; + op->o_bd->be_modify( op, &rs ); + if ( mod.sml_next ) { + slap_mods_free( mod.sml_next, 1 ); + } + } } ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );