return rc;
}
+static int
+ask_syncprov( Operation *op, syncinfo_t *si, Attribute *a )
+{
+ AttributeName at[2];
+ Entry e = {0};
+ SlapReply rs = {0};
+
+ /* Look for contextCSN from syncprov overlay. If
+ * there's no overlay, this will be a no-op. That means
+ * this is a pure consumer, so local changes will not be
+ * allowed, and all changes will already be reflected in
+ * the cookieState.
+ */
+ a->a_desc = slap_schema.si_ad_contextCSN;
+ e.e_attrs = a;
+ e.e_name = si->si_wbe->be_suffix[0];
+ e.e_nname = si->si_wbe->be_nsuffix[0];
+ rs.sr_entry = &e;
+ rs.sr_flags = REP_ENTRY_MODIFIABLE;
+ at[0].an_name = a->a_desc->ad_cname;
+ at[0].an_desc = a->a_desc;
+ BER_BVZERO( &at[1].an_name );
+ op->o_req_dn = e.e_name;
+ op->o_req_ndn = e.e_nname;
+
+ return backend_operational( op, &rs );
+}
+
static int
do_syncrep1(
Operation *op,
ldap_set_option( si->si_ld, LDAP_OPT_TIMELIMIT, &si->si_tlimit );
+ si->si_syncCookie.rid = si->si_rid;
+ si->si_syncCookie.sid = SLAP_SINGLE_SHADOW( si->si_be ) ? -1 :
+ slap_serverID;
+
/* We've just started up, or the remote server hasn't sent us
* any meaningful state.
*/
if ( BER_BVISNULL( &si->si_syncCookie.octet_str ) ) {
int i;
- si->si_syncCookie.rid = si->si_rid;
- si->si_syncCookie.sid = SLAP_SINGLE_SHADOW( si->si_be ) ? -1 :
- slap_serverID;
-
LDAP_STAILQ_FOREACH( sc, &slap_sync_cookie, sc_next ) {
if ( si->si_rid == sc->rid ) {
cmdline_cookie_found = 1;
ldap_pvt_thread_mutex_lock( &si->si_cookieState->cs_mutex );
if ( !si->si_cookieState->cs_num ) {
/* get contextCSN shadow replica from database */
- BerVarray csn = NULL;
+ Attribute a = {0};
void *ctx = op->o_tmpmemctx;
- op->o_req_ndn = op->o_bd->be_nsuffix[0];
- op->o_req_dn = op->o_req_ndn;
-
- /* try to read stored contextCSN */
- op->o_tmpmemctx = NULL;
- backend_attribute( op, NULL, &op->o_req_ndn,
- slap_schema.si_ad_contextCSN, &csn, ACL_READ );
- op->o_tmpmemctx = ctx;
- if ( csn ) {
- si->si_cookieState->cs_vals = csn;
- for (i=0; !BER_BVISNULL( &csn[i] ); i++);
- si->si_cookieState->cs_num = i;
- si->si_cookieState->cs_sids = slap_parse_csn_sids( csn, i, NULL );
+ rc = ask_syncprov( op, si, &a );
+ if ( rc || !a.a_vals ) {
+ /* try to read stored contextCSN */
+ op->o_tmpmemctx = NULL;
+ backend_attribute( op, NULL, &op->o_req_ndn,
+ slap_schema.si_ad_contextCSN, &a.a_vals, ACL_READ );
+ op->o_tmpmemctx = ctx;
+ if ( a.a_vals ) {
+ for (i=0; !BER_BVISNULL( &a.a_vals[i] ); i++);
+ a.a_numvals = i;
+ }
+ }
+ if ( a.a_vals ) {
+ si->si_cookieState->cs_vals = a.a_vals;
+ si->si_cookieState->cs_num = a.a_numvals;
+ si->si_cookieState->cs_sids = slap_parse_csn_sids( a.a_vals, a.a_numvals, NULL );
}
}
if ( si->si_cookieState->cs_num ) {
si->si_syncCookie.ctxcsn, si->si_syncCookie.rid,
si->si_syncCookie.sid );
} else {
- AttributeName at[2];
Attribute a = {0};
- Entry e = {0};
- SlapReply rs = {0};
int i, j, changed = 0;
/* Look for contextCSN from syncprov overlay. If
* allowed, and all changes will already be reflected in
* the cookieState.
*/
- a.a_desc = slap_schema.si_ad_contextCSN;
- e.e_attrs = &a;
- e.e_name = si->si_wbe->be_suffix[0];
- e.e_nname = si->si_wbe->be_nsuffix[0];
- rs.sr_entry = &e;
- rs.sr_flags = REP_ENTRY_MODIFIABLE;
- at[0].an_name = a.a_desc->ad_cname;
- at[0].an_desc = a.a_desc;
- BER_BVZERO( &at[1].an_name );
- op->o_req_dn = e.e_name;
- op->o_req_ndn = e.e_nname;
-
ldap_pvt_thread_mutex_lock( &si->si_cookieState->cs_mutex );
- rc = backend_operational( op, &rs );
+ rc = ask_syncprov( op, si, &a );
if ( rc == LDAP_SUCCESS && a.a_vals ) {
int num = a.a_numvals;
/* check for differences */
ch_free( si->si_syncCookie.octet_str.bv_val );
slap_compose_sync_cookie( NULL, &si->si_syncCookie.octet_str,
si->si_syncCookie.ctxcsn, si->si_syncCookie.rid,
- SLAP_SINGLE_SHADOW( si->si_be ) ? -1 : slap_serverID );
+ si->si_syncCookie.sid );
}
}
ldap_pvt_thread_mutex_unlock( &si->si_cookieState->cs_mutex );