/* syncprov.c - syncrepl provider */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2004-2007 The OpenLDAP Foundation.
+ * Copyright 2004-2008 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
}
if ( si->si_chktime &&
(op->o_time - si->si_chklast >= si->si_chktime )) {
- do_check = 1;
- si->si_chklast = op->o_time;
+ if ( si->si_chklast ) {
+ do_check = 1;
+ si->si_chklast = op->o_time;
+ } else {
+ si->si_chklast = 1;
+ }
}
}
ldap_pvt_thread_rdwr_wunlock( &si->si_csn_rwlock );
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private;
slap_callback *cb;
- int gotstate = 0, changed = 0, do_present;
+ int gotstate = 0, changed = 0, do_present = 0;
syncops *sop = NULL;
searchstate *ss;
sync_control *srs;
return rs->sr_err;
}
- do_present = si->si_nopres ? 0 : SS_PRESENT;
-
srs = op->o_controls[slap_cids.sc_LDAPsync];
op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
if ( !numcsns )
goto no_change;
+ if ( !si->si_nopres )
+ do_present = SS_PRESENT;
+
/* If there are SIDs we don't recognize in the cookie, drop them */
for (i=0; i<srs->sr_state.numcsns; ) {
for (j=0; j<numcsns; j++) {
break;
}
if ( !changed ) {
+ do_present = 0;
no_change: if ( !(op->o_sync_mode & SLAP_SYNC_PERSIST) ) {
LDAPControl *ctrls[2];
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private;
+ /* This prevents generating unnecessarily; frontend will strip
+ * any statically stored copy.
+ */
+ if ( op->o_sync != SLAP_CONTROL_NONE )
+ return SLAP_CB_CONTINUE;
+
if ( rs->sr_entry &&
dn_match( &rs->sr_entry->e_nname, op->o_bd->be_nsuffix )) {
sr->sr_rhint = rhint;
if (!BER_BVISNULL(&cookie)) {
ber_dupbv_x( &sr->sr_state.octet_str, &cookie, op->o_tmpmemctx );
+ /* If parse fails, pretend no cookie was sent */
if ( slap_parse_sync_cookie( &sr->sr_state, op->o_tmpmemctx ) ||
sr->sr_state.rid == -1 ) {
- rs->sr_text = "Sync control : cookie parsing error";
- return LDAP_PROTOCOL_ERROR;
+ if ( sr->sr_state.ctxcsn ) {
+ ber_bvarray_free_x( sr->sr_state.ctxcsn, op->o_tmpmemctx );
+ sr->sr_state.ctxcsn = NULL;
+ }
+ sr->sr_state.numcsns = 0;
}
}