version 1.97, 2005/08/15 03:36:56
|
version 1.98, 2005/08/15 05:18:19
|
Line 1
|
Line 1
|
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.96 2005/08/14 22:04:13 hyc Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.97 2005/08/15 03:36:56 hyc Exp $ */ |
/* syncprov.c - syncrepl provider */ |
/* syncprov.c - syncrepl provider */ |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
* |
* |
Line 1609 typedef struct searchstate {
|
Line 1609 typedef struct searchstate {
|
slap_overinst *ss_on; |
slap_overinst *ss_on; |
syncops *ss_so; |
syncops *ss_so; |
int ss_present; |
int ss_present; |
|
struct berval ss_ctxcsn; |
|
char ss_csnbuf[LDAP_LUTIL_CSNSTR_BUFSIZE]; |
} searchstate; |
} searchstate; |
|
|
static int |
static int |
Line 1707 syncprov_search_response( Operation *op,
|
Line 1709 syncprov_search_response( Operation *op,
|
sync_control *srs = op->o_controls[slap_cids.sc_LDAPsync]; |
sync_control *srs = op->o_controls[slap_cids.sc_LDAPsync]; |
|
|
if ( rs->sr_type == REP_SEARCH || rs->sr_type == REP_SEARCHREF ) { |
if ( rs->sr_type == REP_SEARCH || rs->sr_type == REP_SEARCHREF ) { |
|
Attribute *a; |
/* If we got a referral without a referral object, there's |
/* If we got a referral without a referral object, there's |
* something missing that we cannot replicate. Just ignore it. |
* something missing that we cannot replicate. Just ignore it. |
* The consumer will abort because we didn't send the expected |
* The consumer will abort because we didn't send the expected |
Line 1717 syncprov_search_response( Operation *op,
|
Line 1720 syncprov_search_response( Operation *op,
|
Debug( LDAP_DEBUG_ANY, "bogus referral in context\n",0,0,0 ); |
Debug( LDAP_DEBUG_ANY, "bogus referral in context\n",0,0,0 ); |
return SLAP_CB_CONTINUE; |
return SLAP_CB_CONTINUE; |
} |
} |
if ( !BER_BVISNULL( &srs->sr_state.ctxcsn )) { |
a = attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_entryCSN ); |
Attribute *a = attr_find( rs->sr_entry->e_attrs, |
if ( a ) { |
slap_schema.si_ad_entryCSN ); |
/* Make sure entry is less than the snaphot'd contextCSN */ |
|
if ( ber_bvcmp( &a->a_nvals[0], &ss->ss_ctxcsn ) > 0 ) |
|
return LDAP_SUCCESS; |
|
|
/* Don't send the ctx entry twice */ |
/* Don't send the ctx entry twice */ |
if ( a && bvmatch( &a->a_nvals[0], &srs->sr_state.ctxcsn ) ) |
if ( !BER_BVISNULL( &srs->sr_state.ctxcsn ) && |
|
bvmatch( &a->a_nvals[0], &srs->sr_state.ctxcsn ) ) |
return LDAP_SUCCESS; |
return LDAP_SUCCESS; |
} |
} |
rs->sr_ctrls = op->o_tmpalloc( sizeof(LDAPControl *)*2, |
rs->sr_ctrls = op->o_tmpalloc( sizeof(LDAPControl *)*2, |
Line 1733 syncprov_search_response( Operation *op,
|
Line 1739 syncprov_search_response( Operation *op,
|
} else if ( rs->sr_type == REP_RESULT && rs->sr_err == LDAP_SUCCESS ) { |
} else if ( rs->sr_type == REP_RESULT && rs->sr_err == LDAP_SUCCESS ) { |
struct berval cookie; |
struct berval cookie; |
|
|
slap_compose_sync_cookie( op, &cookie, |
slap_compose_sync_cookie( op, &cookie, &ss->ss_ctxcsn, |
&op->ors_filter->f_and->f_ava->aa_value, |
|
srs->sr_state.rid ); |
srs->sr_state.rid ); |
|
|
/* Is this a regular refresh? */ |
/* Is this a regular refresh? */ |
Line 1780 syncprov_op_search( Operation *op, SlapR
|
Line 1785 syncprov_op_search( Operation *op, SlapR
|
syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private; |
syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private; |
slap_callback *cb; |
slap_callback *cb; |
int gotstate = 0, nochange = 0, do_present = 1; |
int gotstate = 0, nochange = 0, do_present = 1; |
Filter *fand, *fava; |
|
syncops *sop = NULL; |
syncops *sop = NULL; |
searchstate *ss; |
searchstate *ss; |
sync_control *srs; |
sync_control *srs; |
Line 1904 shortcut:
|
Line 1908 shortcut:
|
sop->s_filterstr= op->ors_filterstr; |
sop->s_filterstr= op->ors_filterstr; |
} |
} |
|
|
fand = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx ); |
/* If something changed, find the changes */ |
fand->f_choice = LDAP_FILTER_AND; |
if ( gotstate && !nochange ) { |
fand->f_next = NULL; |
Filter *fand, *fava; |
fava = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx ); |
|
fava->f_choice = LDAP_FILTER_LE; |
fand = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx ); |
fava->f_ava = op->o_tmpalloc( sizeof(AttributeAssertion), op->o_tmpmemctx ); |
fand->f_choice = LDAP_FILTER_AND; |
fava->f_ava->aa_desc = slap_schema.si_ad_entryCSN; |
fand->f_next = NULL; |
#ifdef LDAP_COMP_MATCH |
fava = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx ); |
fava->f_ava->aa_cf = NULL; |
fand->f_and = fava; |
#endif |
|
ber_dupbv_x( &fava->f_ava->aa_value, &ctxcsn, op->o_tmpmemctx ); |
|
fand->f_and = fava; |
|
if ( gotstate ) { |
|
fava->f_next = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx ); |
|
fava = fava->f_next; |
|
fava->f_choice = LDAP_FILTER_GE; |
fava->f_choice = LDAP_FILTER_GE; |
fava->f_ava = op->o_tmpalloc( sizeof(AttributeAssertion), op->o_tmpmemctx ); |
fava->f_ava = op->o_tmpalloc( sizeof(AttributeAssertion), op->o_tmpmemctx ); |
fava->f_ava->aa_desc = slap_schema.si_ad_entryCSN; |
fava->f_ava->aa_desc = slap_schema.si_ad_entryCSN; |
Line 1926 shortcut:
|
Line 1924 shortcut:
|
fava->f_ava->aa_cf = NULL; |
fava->f_ava->aa_cf = NULL; |
#endif |
#endif |
ber_dupbv_x( &fava->f_ava->aa_value, &srs->sr_state.ctxcsn, op->o_tmpmemctx ); |
ber_dupbv_x( &fava->f_ava->aa_value, &srs->sr_state.ctxcsn, op->o_tmpmemctx ); |
|
fava->f_next = op->ors_filter; |
|
op->ors_filter = fand; |
|
filter2bv_x( op, op->ors_filter, &op->ors_filterstr ); |
} |
} |
fava->f_next = op->ors_filter; |
|
op->ors_filter = fand; |
|
filter2bv_x( op, op->ors_filter, &op->ors_filterstr ); |
|
|
|
/* Let our callback add needed info to returned entries */ |
/* Let our callback add needed info to returned entries */ |
cb = op->o_tmpcalloc(1, sizeof(slap_callback)+sizeof(searchstate), op->o_tmpmemctx); |
cb = op->o_tmpcalloc(1, sizeof(slap_callback)+sizeof(searchstate), op->o_tmpmemctx); |
Line 1937 shortcut:
|
Line 1935 shortcut:
|
ss->ss_on = on; |
ss->ss_on = on; |
ss->ss_so = sop; |
ss->ss_so = sop; |
ss->ss_present = do_present; |
ss->ss_present = do_present; |
|
ss->ss_ctxcsn.bv_len = ctxcsn.bv_len; |
|
ss->ss_ctxcsn.bv_val = ss->ss_csnbuf; |
|
strcpy( ss->ss_ctxcsn.bv_val, ctxcsn.bv_val ); |
cb->sc_response = syncprov_search_response; |
cb->sc_response = syncprov_search_response; |
cb->sc_cleanup = syncprov_search_cleanup; |
cb->sc_cleanup = syncprov_search_cleanup; |
cb->sc_private = ss; |
cb->sc_private = ss; |