ITS#4704 use an old CSN while purging log.

This commit is contained in:
Howard Chu 2006-11-07 02:12:29 +00:00
parent 9cd4f91ac9
commit d3dc069a62

View File

@ -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; i<pd.used; i++) {
op->o_req_dn = pd.dn[i];