Add some asserts on CSN validity

This commit is contained in:
Howard Chu 2009-02-11 22:00:00 +00:00
parent 58437e838a
commit 686ceac31f
2 changed files with 30 additions and 0 deletions

View File

@ -1339,7 +1339,14 @@ syncprov_checkpoint( Operation *op, SlapReply *rs, slap_overinst *on )
SlapReply rsm = { 0 };
slap_callback cb = {0};
BackendDB be;
#ifdef CHECK_CSN
Syntax *syn = slap_schema.si_ad_contextCSN->ad_type->sat_syntax;
int i;
for ( i=0; i<si->si_numcsns; i++ ) {
assert( !syn->ssyn_validate( syn, si->si_ctxcsn+i ));
}
#endif
mod.sml_numvals = si->si_numcsns;
mod.sml_values = si->si_ctxcsn;
mod.sml_nvalues = NULL;
@ -1367,6 +1374,11 @@ syncprov_checkpoint( Operation *op, SlapReply *rs, slap_overinst *on )
if ( mod.sml_next != NULL ) {
slap_mods_free( mod.sml_next, 1 );
}
#ifdef CHECK_CSN
for ( i=0; i<si->si_numcsns; i++ ) {
assert( !syn->ssyn_validate( syn, si->si_ctxcsn+i ));
}
#endif
}
static void

View File

@ -2876,6 +2876,9 @@ syncrepl_updateCookie(
Backend *be = op->o_bd;
Modifications mod;
struct berval first = BER_BVNULL;
#ifdef CHECK_CSN
Syntax *syn = slap_schema.si_ad_contextCSN->ad_type->sat_syntax;
#endif
int rc, i, j;
ber_len_t len;
@ -2892,6 +2895,15 @@ syncrepl_updateCookie(
ldap_pvt_thread_mutex_lock( &si->si_cookieState->cs_mutex );
#ifdef CHECK_CSN
for ( i=0; i<syncCookie->numcsns; i++ ) {
assert( !syn->ssyn_validate( syn, syncCookie->ctxcsn+i ));
}
for ( i=0; i<si->si_cookieState->cs_num; i++ ) {
assert( !syn->ssyn_validate( syn, si->si_cookieState->cs_vals+i ));
}
#endif
/* clone the cookieState CSNs so we can Replace the whole thing */
mod.sml_numvals = si->si_cookieState->cs_num;
mod.sml_values = op->o_tmpalloc(( mod.sml_numvals+1 )*sizeof(struct berval), op->o_tmpmemctx );
@ -2994,6 +3006,12 @@ syncrepl_updateCookie(
if ( mod.sml_next ) slap_mods_free( mod.sml_next, 1 );
op->o_tmpfree( mod.sml_values, op->o_tmpmemctx );
#ifdef CHECK_CSN
for ( i=0; i<si->si_cookieState->cs_num; i++ ) {
assert( !syn->ssyn_validate( syn, si->si_cookieState->cs_vals+i ));
}
#endif
return rc;
}