+ if ( op->o_tag == LDAP_REQ_MODIFY &&
+ op->orm_modlist->sml_op == LDAP_MOD_REPLACE &&
+ op->orm_modlist->sml_desc == slap_schema.si_ad_contextCSN ) {
+ /* Catch contextCSN updates from syncrepl. We have to look at
+ * all the attribute values, as there may be more than one csn
+ * that changed, and only one can be passed in the csn queue.
+ */
+ Modifications *mod = op->orm_modlist;
+ int i, j, sid;
+
+ for ( i=0; i<mod->sml_numvals; i++ ) {
+ sid = slap_parse_csn_sid( &mod->sml_values[i] );
+ for ( j=0; j<si->si_numcsns; j++ ) {
+ if ( sid == si->si_sids[j] ) {
+ if ( ber_bvcmp( &mod->sml_values[i], &si->si_ctxcsn[j] ) > 0 ) {
+ ber_bvreplace( &si->si_ctxcsn[j], &mod->sml_values[i] );
+ csn_changed = 1;
+ }
+ break;
+ }
+ }
+
+ if ( j == si->si_numcsns ) {
+ value_add_one( &si->si_ctxcsn, &mod->sml_values[i] );
+ si->si_numcsns++;
+ si->si_sids = ch_realloc( si->si_sids, si->si_numcsns *
+ sizeof(int));
+ si->si_sids[j] = sid;
+ csn_changed = 1;
+ }
+ }
+ if ( csn_changed )
+ si->si_dirty = 0;