if ( dd ) {
len = snprintf( ptr, size, "%d+", dd );
- assert( len >= 0 && len < size );
+ assert( len >= 0 && (unsigned) len < size );
size -= len;
ptr += len;
}
len = snprintf( ptr, size, "%02d:%02d", hh, mm );
- assert( len >= 0 && len < size );
+ assert( len >= 0 && (unsigned) len < size );
size -= len;
ptr += len;
if ( ss ) {
len = snprintf( ptr, size, ":%02d", ss );
- assert( len >= 0 && len < size );
+ assert( len >= 0 && (unsigned) len < size );
size -= len;
ptr += len;
}
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 ) {
+ ber_len_t 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;
}
if ( pd.used ) {
int i;
+ /* delete the expired entries */
op->o_tag = LDAP_REQ_DELETE;
op->o_callback = &nullsc;
op->o_csn = pd.csn;
}
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 );
struct berval *valp )
{
struct berval val, bv;
- int i;
+ ber_len_t i;
int rc = LDAP_SUCCESS;
assert( valp != NULL );
}
if ( !BER_BVISNULL( &ctrls[ i ]->ldctl_value ) ) {
- int j;
+ ber_len_t j;
ptr = lutil_strcopy( ptr, " controlValue \"" );
for ( j = 0; j < ctrls[ i ]->ldctl_value.bv_len; j++ )
old = li->li_old;
li->li_old = NULL;
/* Disarm mod_cleanup */
- for ( cb = op->o_callback->sc_next; cb; cb = cb->sc_next ) {
+ for ( cb = op->o_callback; cb; cb = cb->sc_next ) {
if ( cb->sc_private == (void *)on ) {
cb->sc_private = NULL;
break;
attr_merge_one( e, ad_reqMessage, &bv, NULL );
}
bv.bv_len = snprintf( timebuf, sizeof( timebuf ), "%d", rs->sr_err );
- if ( bv.bv_len >= 0 && bv.bv_len < sizeof( timebuf ) ) {
+ if ( bv.bv_len < sizeof( timebuf ) ) {
bv.bv_val = timebuf;
attr_merge_one( e, ad_reqResult, &bv, NULL );
}
}
bv.bv_val = timebuf;
bv.bv_len = snprintf( bv.bv_val, sizeof( timebuf ), "%d", rs->sr_nentries );
- if ( bv.bv_len >= 0 && bv.bv_len < sizeof( timebuf ) ) {
+ if ( bv.bv_len < sizeof( timebuf ) ) {
attr_merge_one( e, ad_reqEntries, &bv, NULL );
} /* else? */
bv.bv_len = snprintf( bv.bv_val, sizeof( timebuf ), "%d", op->ors_tlimit );
- if ( bv.bv_len >= 0 && bv.bv_len < sizeof( timebuf ) ) {
+ if ( bv.bv_len < sizeof( timebuf ) ) {
attr_merge_one( e, ad_reqTimeLimit, &bv, NULL );
} /* else? */
bv.bv_len = snprintf( bv.bv_val, sizeof( timebuf ), "%d", op->ors_slimit );
- if ( bv.bv_len >= 0 && bv.bv_len < sizeof( timebuf ) ) {
+ if ( bv.bv_len < sizeof( timebuf ) ) {
attr_merge_one( e, ad_reqSizeLimit, &bv, NULL );
} /* else? */
break;
case LOG_EN_BIND:
bv.bv_val = timebuf;
bv.bv_len = snprintf( bv.bv_val, sizeof( timebuf ), "%d", op->o_protocol );
- if ( bv.bv_len >= 0 && bv.bv_len < sizeof( timebuf ) ) {
+ if ( bv.bv_len < sizeof( timebuf ) ) {
attr_merge_one( e, ad_reqVersion, &bv, NULL );
} /* else? */
if ( op->orb_method == LDAP_AUTH_SIMPLE ) {
e = accesslog_entry( op, rs, LOG_EN_ABANDON, &op2 );
bv.bv_val = buf;
bv.bv_len = snprintf( buf, sizeof( buf ), "%d", op->orn_msgid );
- if ( bv.bv_len >= 0 && bv.bv_len < sizeof( buf ) ) {
+ if ( bv.bv_len < sizeof( buf ) ) {
attr_merge_one( e, ad_reqId, &bv, NULL );
} /* else? */