From: Howard Chu Date: Tue, 7 Nov 2006 02:12:29 +0000 (+0000) Subject: ITS#4704 use an old CSN while purging log. X-Git-Tag: OPENLDAP_REL_ENG_2_3_MP~6 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d3dc069a620f3510bc7f29c7b1a82a6d178a4276;p=openldap ITS#4704 use an old CSN while purging log. --- diff --git a/servers/slapd/overlays/accesslog.c b/servers/slapd/overlays/accesslog.c index b57c197cf7..c7b7f5415b 100644 --- a/servers/slapd/overlays/accesslog.c +++ b/servers/slapd/overlays/accesslog.c @@ -495,6 +495,7 @@ typedef struct purge_data { int used; BerVarray dn; BerVarray ndn; + struct berval csn; /* an arbitrary old CSN */ } purge_data; static int @@ -506,6 +507,18 @@ log_old_lookup( Operation *op, SlapReply *rs ) 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; + AC_MEMCPY( pd->csn.bv_val, a->a_vals[0].bv_val, len ); + pd->csn.bv_len = len; + } + } if ( pd->used >= pd->slots ) { pd->slots += PURGE_INCREMENT; pd->dn = ch_realloc( pd->dn, pd->slots * sizeof( struct berval )); @@ -533,6 +546,7 @@ accesslog_purge( void *ctx, void *arg ) AttributeAssertion ava = {0}; purge_data pd = {0}; char timebuf[LDAP_LUTIL_GENTIME_BUFSIZE]; + char csnbuf[LDAP_LUTIL_CSNSTR_BUFSIZE]; time_t old = slap_get_time(); connection_fake_init( &conn, op, ctx ); @@ -564,6 +578,9 @@ accesslog_purge( void *ctx, void *arg ) op->ors_attrs = slap_anlist_no_attrs; op->ors_attrsonly = 1; + pd.csn.bv_len = sizeof( csnbuf ); + pd.csn.bv_val = csnbuf; + csnbuf[0] = '\0'; cb.sc_private = &pd; op->o_bd->be_search( op, &rs ); @@ -574,6 +591,7 @@ accesslog_purge( void *ctx, void *arg ) op->o_tag = LDAP_REQ_DELETE; op->o_callback = &nullsc; + op->o_csn = pd.csn; for (i=0; io_req_dn = pd.dn[i];