version 1.147.2.46, 2009/02/23 02:15:32
|
version 1.224, 2008/03/20 23:09:24
|
Line 1
|
Line 1
|
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.147.2.45 2009/02/17 00:06:01 quanah Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.223 2008/03/19 23:31:42 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/>. |
* |
* |
* Copyright 2004-2009 The OpenLDAP Foundation. |
* Copyright 2004-2008 The OpenLDAP Foundation. |
* All rights reserved. |
* All rights reserved. |
* |
* |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
Line 28
|
Line 28
|
#include "config.h" |
#include "config.h" |
#include "ldap_rq.h" |
#include "ldap_rq.h" |
|
|
#ifdef LDAP_DEVEL |
|
#define CHECK_CSN 1 |
|
#endif |
|
|
|
/* A modify request on a particular entry */ |
/* A modify request on a particular entry */ |
typedef struct modinst { |
typedef struct modinst { |
struct modinst *mi_next; |
struct modinst *mi_next; |
Line 397 static struct berval generic_filterstr =
|
Line 393 static struct berval generic_filterstr =
|
static int |
static int |
syncprov_findbase( Operation *op, fbase_cookie *fc ) |
syncprov_findbase( Operation *op, fbase_cookie *fc ) |
{ |
{ |
|
opcookie *opc = op->o_callback->sc_private; |
|
slap_overinst *on = opc->son; |
|
|
/* Use basic parameters from syncrepl search, but use |
/* Use basic parameters from syncrepl search, but use |
* current op's threadctx / tmpmemctx |
* current op's threadctx / tmpmemctx |
*/ |
*/ |
Line 405 syncprov_findbase( Operation *op, fbase_
|
Line 404 syncprov_findbase( Operation *op, fbase_
|
slap_callback cb = {0}; |
slap_callback cb = {0}; |
Operation fop; |
Operation fop; |
SlapReply frs = { REP_RESULT }; |
SlapReply frs = { REP_RESULT }; |
|
BackendInfo *bi; |
int rc; |
int rc; |
|
|
fc->fss->s_flags ^= PS_FIND_BASE; |
fc->fss->s_flags ^= PS_FIND_BASE; |
Line 412 syncprov_findbase( Operation *op, fbase_
|
Line 412 syncprov_findbase( Operation *op, fbase_
|
|
|
fop = *fc->fss->s_op; |
fop = *fc->fss->s_op; |
|
|
fop.o_bd = fop.o_bd->bd_self; |
|
fop.o_hdr = op->o_hdr; |
fop.o_hdr = op->o_hdr; |
|
fop.o_bd = op->o_bd; |
fop.o_time = op->o_time; |
fop.o_time = op->o_time; |
fop.o_tincr = op->o_tincr; |
fop.o_tincr = op->o_tincr; |
|
bi = op->o_bd->bd_info; |
|
|
cb.sc_response = findbase_cb; |
cb.sc_response = findbase_cb; |
cb.sc_private = fc; |
cb.sc_private = fc; |
Line 433 syncprov_findbase( Operation *op, fbase_
|
Line 434 syncprov_findbase( Operation *op, fbase_
|
fop.ors_filter = &generic_filter; |
fop.ors_filter = &generic_filter; |
fop.ors_filterstr = generic_filterstr; |
fop.ors_filterstr = generic_filterstr; |
|
|
rc = fop.o_bd->be_search( &fop, &frs ); |
rc = overlay_op_walk( &fop, &frs, op_search, on->on_info, on ); |
|
op->o_bd->bd_info = bi; |
} else { |
} else { |
ldap_pvt_thread_mutex_unlock( &fc->fss->s_mutex ); |
ldap_pvt_thread_mutex_unlock( &fc->fss->s_mutex ); |
fc->fbase = 1; |
fc->fbase = 1; |
Line 498 findmax_cb( Operation *op, SlapReply *rs
|
Line 500 findmax_cb( Operation *op, SlapReply *rs
|
Attribute *a = attr_find( rs->sr_entry->e_attrs, |
Attribute *a = attr_find( rs->sr_entry->e_attrs, |
slap_schema.si_ad_entryCSN ); |
slap_schema.si_ad_entryCSN ); |
|
|
if ( a && ber_bvcmp( &a->a_vals[0], maxcsn ) > 0 && |
if ( a && ber_bvcmp( &a->a_vals[0], maxcsn ) > 0 ) { |
slap_parse_csn_sid( &a->a_vals[0] ) == slap_serverID ) { |
|
maxcsn->bv_len = a->a_vals[0].bv_len; |
maxcsn->bv_len = a->a_vals[0].bv_len; |
strcpy( maxcsn->bv_val, a->a_vals[0].bv_val ); |
strcpy( maxcsn->bv_val, a->a_vals[0].bv_val ); |
} |
} |
Line 589 syncprov_findcsn( Operation *op, find_cs
|
Line 590 syncprov_findcsn( Operation *op, find_cs
|
sync_control *srs = NULL; |
sync_control *srs = NULL; |
struct slap_limits_set fc_limits; |
struct slap_limits_set fc_limits; |
int i, rc = LDAP_SUCCESS, findcsn_retry = 1; |
int i, rc = LDAP_SUCCESS, findcsn_retry = 1; |
int maxid; |
int maxid = 0; |
|
|
if ( mode != FIND_MAXCSN ) { |
if ( mode != FIND_MAXCSN ) { |
srs = op->o_controls[slap_cids.sc_LDAPsync]; |
srs = op->o_controls[slap_cids.sc_LDAPsync]; |
Line 615 again:
|
Line 616 again:
|
switch( mode ) { |
switch( mode ) { |
case FIND_MAXCSN: |
case FIND_MAXCSN: |
cf.f_choice = LDAP_FILTER_GE; |
cf.f_choice = LDAP_FILTER_GE; |
/* If there are multiple CSNs, use the one with our serverID */ |
cf.f_av_value = si->si_ctxcsn[0]; |
for ( i=0; i<si->si_numcsns; i++) { |
/* If there are multiple CSNs, use the largest */ |
if ( slap_serverID == si->si_sids[i] ) { |
for ( i=1; i<si->si_numcsns; i++) { |
|
if ( ber_bvcmp( &cf.f_av_value, &si->si_ctxcsn[i] ) < 0 ) { |
|
cf.f_av_value = si->si_ctxcsn[i]; |
maxid = i; |
maxid = i; |
break; |
|
} |
} |
} |
} |
if ( i == si->si_numcsns ) { |
|
/* No match: this is multimaster, and none of the content in the DB |
|
* originated locally. Treat like no CSN. |
|
*/ |
|
return LDAP_NO_SUCH_OBJECT; |
|
} |
|
cf.f_av_value = si->si_ctxcsn[maxid]; |
|
fop.ors_filterstr.bv_len = snprintf( buf, sizeof( buf ), |
fop.ors_filterstr.bv_len = snprintf( buf, sizeof( buf ), |
"(entryCSN>=%s)", cf.f_av_value.bv_val ); |
"(entryCSN>=%s)", cf.f_av_value.bv_val ); |
if ( fop.ors_filterstr.bv_len >= sizeof( buf ) ) { |
if ( fop.ors_filterstr.bv_len < 0 || fop.ors_filterstr.bv_len >= sizeof( buf ) ) { |
return LDAP_OTHER; |
return LDAP_OTHER; |
} |
} |
fop.ors_attrsonly = 0; |
fop.ors_attrsonly = 0; |
Line 668 again:
|
Line 663 again:
|
fop.ors_filterstr.bv_len = snprintf( buf, sizeof( buf ), |
fop.ors_filterstr.bv_len = snprintf( buf, sizeof( buf ), |
"(entryCSN<=%s)", cf.f_av_value.bv_val ); |
"(entryCSN<=%s)", cf.f_av_value.bv_val ); |
} |
} |
if ( fop.ors_filterstr.bv_len >= sizeof( buf ) ) { |
if ( fop.ors_filterstr.bv_len < 0 || fop.ors_filterstr.bv_len >= sizeof( buf ) ) { |
return LDAP_OTHER; |
return LDAP_OTHER; |
} |
} |
fop.ors_attrsonly = 1; |
fop.ors_attrsonly = 1; |
Line 701 again:
|
Line 696 again:
|
break; |
break; |
} |
} |
|
|
fop.o_bd->bd_info = (BackendInfo *)on->on_info; |
if ( on->on_next ) |
|
fop.o_bd->bd_info = (BackendInfo *)on->on_next; |
|
else |
|
fop.o_bd->bd_info = on->on_info->oi_orig; |
fop.o_bd->be_search( &fop, &frs ); |
fop.o_bd->be_search( &fop, &frs ); |
fop.o_bd->bd_info = (BackendInfo *)on; |
fop.o_bd->bd_info = (BackendInfo *)on; |
|
|
switch( mode ) { |
switch( mode ) { |
case FIND_MAXCSN: |
case FIND_MAXCSN: |
if ( ber_bvcmp( &si->si_ctxcsn[maxid], &maxcsn )) { |
if ( ber_bvcmp( &si->si_ctxcsn[maxid], &maxcsn )) { |
#ifdef CHECK_CSN |
|
Syntax *syn = slap_schema.si_ad_contextCSN->ad_type->sat_syntax; |
|
assert( !syn->ssyn_validate( syn, &maxcsn )); |
|
#endif |
|
ber_bvreplace( &si->si_ctxcsn[maxid], &maxcsn ); |
ber_bvreplace( &si->si_ctxcsn[maxid], &maxcsn ); |
si->si_numops++; /* ensure a checkpoint */ |
si->si_numops++; /* ensure a checkpoint */ |
} |
} |
Line 746 syncprov_free_syncop( syncops *so )
|
Line 740 syncprov_free_syncop( syncops *so )
|
ldap_pvt_thread_mutex_unlock( &so->s_mutex ); |
ldap_pvt_thread_mutex_unlock( &so->s_mutex ); |
return; |
return; |
} |
} |
if ( so->s_qtask ) { |
|
ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); |
|
if ( ldap_pvt_runqueue_isrunning( &slapd_rq, so->s_qtask ) ) |
|
ldap_pvt_runqueue_stoptask( &slapd_rq, so->s_qtask ); |
|
ldap_pvt_runqueue_remove( &slapd_rq, so->s_qtask ); |
|
ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); |
|
} |
|
ldap_pvt_thread_mutex_unlock( &so->s_mutex ); |
ldap_pvt_thread_mutex_unlock( &so->s_mutex ); |
if ( so->s_flags & PS_IS_DETACHED ) { |
if ( so->s_flags & PS_IS_DETACHED ) { |
filter_free( so->s_op->ors_filter ); |
filter_free( so->s_op->ors_filter ); |
Line 808 syncprov_sendresp( Operation *op, opcook
|
Line 795 syncprov_sendresp( Operation *op, opcook
|
rs.sr_entry = *e; |
rs.sr_entry = *e; |
if ( rs.sr_entry->e_private ) |
if ( rs.sr_entry->e_private ) |
rs.sr_flags = REP_ENTRY_MUSTRELEASE; |
rs.sr_flags = REP_ENTRY_MUSTRELEASE; |
if ( opc->sreference && so->s_op->o_managedsait <= SLAP_CONTROL_IGNORED ) { |
if ( opc->sreference ) { |
rs.sr_ref = get_entry_referrals( op, rs.sr_entry ); |
rs.sr_ref = get_entry_referrals( op, rs.sr_entry ); |
rs.sr_err = send_search_reference( op, &rs ); |
rs.sr_err = send_search_reference( op, &rs ); |
ber_bvarray_free( rs.sr_ref ); |
ber_bvarray_free( rs.sr_ref ); |
Line 831 syncprov_sendresp( Operation *op, opcook
|
Line 818 syncprov_sendresp( Operation *op, opcook
|
e_uuid.e_name = opc->sdn; |
e_uuid.e_name = opc->sdn; |
e_uuid.e_nname = opc->sndn; |
e_uuid.e_nname = opc->sndn; |
rs.sr_entry = &e_uuid; |
rs.sr_entry = &e_uuid; |
if ( opc->sreference && so->s_op->o_managedsait <= SLAP_CONTROL_IGNORED ) { |
if ( opc->sreference ) { |
struct berval bv = BER_BVNULL; |
struct berval bv = BER_BVNULL; |
rs.sr_ref = &bv; |
rs.sr_ref = &bv; |
rs.sr_err = send_search_reference( op, &rs ); |
rs.sr_err = send_search_reference( op, &rs ); |
Line 916 syncprov_qplay( Operation *op, struct re
|
Line 903 syncprov_qplay( Operation *op, struct re
|
} else { |
} else { |
/* bail out on any error */ |
/* bail out on any error */ |
ldap_pvt_runqueue_remove( &slapd_rq, rtask ); |
ldap_pvt_runqueue_remove( &slapd_rq, rtask ); |
|
|
/* Prevent duplicate remove */ |
|
if ( so->s_qtask == rtask ) |
|
so->s_qtask = NULL; |
|
} |
} |
ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); |
ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); |
ldap_pvt_thread_mutex_unlock( &so->s_mutex ); |
ldap_pvt_thread_mutex_unlock( &so->s_mutex ); |
Line 1189 syncprov_matchops( Operation *op, opcook
|
Line 1172 syncprov_matchops( Operation *op, opcook
|
for (ss = si->si_ops, sprev = (syncops *)&si->si_ops; ss; |
for (ss = si->si_ops, sprev = (syncops *)&si->si_ops; ss; |
sprev = ss, ss=snext) |
sprev = ss, ss=snext) |
{ |
{ |
Operation op2; |
|
Opheader oh; |
|
syncmatches *sm; |
syncmatches *sm; |
int found = 0; |
int found = 0; |
|
|
snext = ss->s_next; |
snext = ss->s_next; |
if ( ss->s_op->o_abandon ) |
|
continue; |
|
|
|
/* validate base */ |
/* validate base */ |
fc.fss = ss; |
fc.fss = ss; |
fc.fbase = 0; |
fc.fbase = 0; |
Line 1238 syncprov_matchops( Operation *op, opcook
|
Line 1216 syncprov_matchops( Operation *op, opcook
|
} |
} |
} |
} |
|
|
if ( fc.fscope ) { |
|
op2 = *ss->s_op; |
|
oh = *op->o_hdr; |
|
oh.oh_conn = ss->s_op->o_conn; |
|
oh.oh_connid = ss->s_op->o_connid; |
|
op2.o_hdr = &oh; |
|
op2.o_extra = op->o_extra; |
|
} |
|
|
|
/* check if current o_req_dn is in scope and matches filter */ |
/* check if current o_req_dn is in scope and matches filter */ |
if ( fc.fscope && test_filter( &op2, e, ss->s_op->ors_filter ) == |
if ( fc.fscope && test_filter( ss->s_op, e, ss->s_op->ors_filter ) == |
LDAP_COMPARE_TRUE ) { |
LDAP_COMPARE_TRUE ) { |
if ( saveit ) { |
if ( saveit ) { |
sm = op->o_tmpalloc( sizeof(syncmatches), op->o_tmpmemctx ); |
sm = op->o_tmpalloc( sizeof(syncmatches), op->o_tmpmemctx ); |
Line 1267 syncprov_matchops( Operation *op, opcook
|
Line 1236 syncprov_matchops( Operation *op, opcook
|
/* send DELETE */ |
/* send DELETE */ |
syncprov_qresp( opc, ss, LDAP_SYNC_DELETE ); |
syncprov_qresp( opc, ss, LDAP_SYNC_DELETE ); |
} |
} |
if ( !saveit && found ) { |
|
/* Decrement s_inuse, was incremented when called |
|
* with saveit == TRUE |
|
*/ |
|
syncprov_free_syncop( ss ); |
|
} |
|
} |
} |
ldap_pvt_thread_mutex_unlock( &si->si_ops_mutex ); |
ldap_pvt_thread_mutex_unlock( &si->si_ops_mutex ); |
|
|
Line 1347 syncprov_checkpoint( Operation *op, Slap
|
Line 1310 syncprov_checkpoint( Operation *op, Slap
|
SlapReply rsm = { 0 }; |
SlapReply rsm = { 0 }; |
slap_callback cb = {0}; |
slap_callback cb = {0}; |
BackendDB be; |
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_numvals = si->si_numcsns; |
mod.sml_values = si->si_ctxcsn; |
mod.sml_values = si->si_ctxcsn; |
mod.sml_nvalues = NULL; |
mod.sml_nvalues = NULL; |
mod.sml_desc = slap_schema.si_ad_contextCSN; |
mod.sml_desc = slap_schema.si_ad_contextCSN; |
mod.sml_op = LDAP_MOD_REPLACE; |
mod.sml_op = LDAP_MOD_REPLACE; |
mod.sml_flags = SLAP_MOD_INTERNAL; |
mod.sml_flags = 0; |
mod.sml_next = NULL; |
mod.sml_next = NULL; |
|
|
cb.sc_response = slap_null_cb; |
cb.sc_response = slap_null_cb; |
Line 1382 syncprov_checkpoint( Operation *op, Slap
|
Line 1338 syncprov_checkpoint( Operation *op, Slap
|
if ( mod.sml_next != NULL ) { |
if ( mod.sml_next != NULL ) { |
slap_mods_free( mod.sml_next, 1 ); |
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 |
static void |
Line 1580 syncprov_playlog( Operation *op, SlapRep
|
Line 1531 syncprov_playlog( Operation *op, SlapRep
|
fop.ors_filter = ⁡ |
fop.ors_filter = ⁡ |
|
|
cb.sc_response = playlog_cb; |
cb.sc_response = playlog_cb; |
fop.o_bd->bd_info = (BackendInfo *)on->on_info; |
if ( on->on_next ) |
|
fop.o_bd->bd_info = (BackendInfo *)on->on_next; |
|
else |
|
fop.o_bd->bd_info = on->on_info->oi_orig; |
|
|
for ( i=ndel; i<num; i++ ) { |
for ( i=ndel; i<num; i++ ) { |
if ( uuids[i].bv_len == 0 ) continue; |
if ( uuids[i].bv_len == 0 ) continue; |
Line 1604 syncprov_playlog( Operation *op, SlapRep
|
Line 1558 syncprov_playlog( Operation *op, SlapRep
|
if ( delcsn[0].bv_len ) { |
if ( delcsn[0].bv_len ) { |
slap_compose_sync_cookie( op, &cookie, delcsn, srs->sr_state.rid, |
slap_compose_sync_cookie( op, &cookie, delcsn, srs->sr_state.rid, |
srs->sr_state.sid ); |
srs->sr_state.sid ); |
|
|
Debug( LDAP_DEBUG_SYNC, "syncprov_playlog: cookie=%s\n", cookie.bv_val, 0, 0 ); |
|
} |
} |
|
|
|
Debug( LDAP_DEBUG_SYNC, "syncprov_playlog: cookie=%s\n", cookie.bv_val, 0, 0 ); |
|
|
uuids[ndel].bv_val = NULL; |
uuids[ndel].bv_val = NULL; |
syncprov_sendinfo( op, rs, LDAP_TAG_SYNC_ID_SET, |
syncprov_sendinfo( op, rs, LDAP_TAG_SYNC_ID_SET, |
delcsn[0].bv_len ? &cookie : NULL, 0, uuids, 1 ); |
delcsn[0].bv_len ? &cookie : NULL, 0, uuids, 1 ); |
if ( delcsn[0].bv_len ) { |
op->o_tmpfree( cookie.bv_val, op->o_tmpmemctx ); |
op->o_tmpfree( cookie.bv_val, op->o_tmpmemctx ); |
|
} |
|
} |
} |
op->o_tmpfree( uuids, op->o_tmpmemctx ); |
op->o_tmpfree( uuids, op->o_tmpmemctx ); |
} |
} |
Line 1628 syncprov_op_response( Operation *op, Sla
|
Line 1580 syncprov_op_response( Operation *op, Sla
|
|
|
if ( rs->sr_err == LDAP_SUCCESS ) |
if ( rs->sr_err == LDAP_SUCCESS ) |
{ |
{ |
struct berval maxcsn; |
struct berval maxcsn = BER_BVNULL; |
char cbuf[LDAP_LUTIL_CSNSTR_BUFSIZE]; |
char cbuf[LDAP_LUTIL_CSNSTR_BUFSIZE]; |
int do_check = 0, have_psearches, foundit, csn_changed = 0; |
int do_check = 0, have_psearches; |
|
|
/* Update our context CSN */ |
/* Update our context CSN */ |
cbuf[0] = '\0'; |
cbuf[0] = '\0'; |
maxcsn.bv_val = cbuf; |
|
maxcsn.bv_len = sizeof(cbuf); |
|
ldap_pvt_thread_rdwr_wlock( &si->si_csn_rwlock ); |
ldap_pvt_thread_rdwr_wlock( &si->si_csn_rwlock ); |
slap_get_commit_csn( op, &maxcsn, &foundit ); |
slap_get_commit_csn( op, &maxcsn ); |
if ( BER_BVISEMPTY( &maxcsn ) && SLAP_GLUE_SUBORDINATE( op->o_bd )) { |
if ( !BER_BVISNULL( &maxcsn ) ) { |
/* syncrepl queues the CSN values in the db where |
|
* it is configured , not where the changes are made. |
|
* So look for a value in the glue db if we didn't |
|
* find any in this db. |
|
*/ |
|
BackendDB *be = op->o_bd; |
|
op->o_bd = select_backend( &be->be_nsuffix[0], 1); |
|
maxcsn.bv_val = cbuf; |
|
maxcsn.bv_len = sizeof(cbuf); |
|
slap_get_commit_csn( op, &maxcsn, &foundit ); |
|
op->o_bd = be; |
|
} |
|
if ( !BER_BVISEMPTY( &maxcsn ) ) { |
|
int i, sid; |
int i, sid; |
#ifdef CHECK_CSN |
strcpy( cbuf, maxcsn.bv_val ); |
Syntax *syn = slap_schema.si_ad_contextCSN->ad_type->sat_syntax; |
|
assert( !syn->ssyn_validate( syn, &maxcsn )); |
|
#endif |
|
sid = slap_parse_csn_sid( &maxcsn ); |
sid = slap_parse_csn_sid( &maxcsn ); |
for ( i=0; i<si->si_numcsns; i++ ) { |
for ( i=0; i<si->si_numcsns; i++ ) { |
if ( sid == si->si_sids[i] ) { |
if ( sid == si->si_sids[i] ) { |
if ( ber_bvcmp( &maxcsn, &si->si_ctxcsn[i] ) > 0 ) { |
if ( ber_bvcmp( &maxcsn, &si->si_ctxcsn[i] ) > 0 ) { |
ber_bvreplace( &si->si_ctxcsn[i], &maxcsn ); |
ber_bvreplace( &si->si_ctxcsn[i], &maxcsn ); |
csn_changed = 1; |
|
} |
} |
break; |
break; |
} |
} |
Line 1670 syncprov_op_response( Operation *op, Sla
|
Line 1603 syncprov_op_response( Operation *op, Sla
|
/* It's a new SID for us */ |
/* It's a new SID for us */ |
if ( i == si->si_numcsns ) { |
if ( i == si->si_numcsns ) { |
value_add_one( &si->si_ctxcsn, &maxcsn ); |
value_add_one( &si->si_ctxcsn, &maxcsn ); |
csn_changed = 1; |
|
si->si_numcsns++; |
si->si_numcsns++; |
si->si_sids = ch_realloc( si->si_sids, si->si_numcsns * |
si->si_sids = ch_realloc( si->si_sids, si->si_numcsns * |
sizeof(int)); |
sizeof(int)); |
si->si_sids[i] = sid; |
si->si_sids[i] = sid; |
} |
} |
} else if ( !foundit ) { |
|
/* internal ops that aren't meant to be replicated */ |
|
ldap_pvt_thread_rdwr_wunlock( &si->si_csn_rwlock ); |
|
return SLAP_CB_CONTINUE; |
|
} |
} |
|
|
/* Don't do any processing for consumer contextCSN updates */ |
/* Don't do any processing for consumer contextCSN updates */ |
if ( op->o_dont_replicate ) { |
if ( SLAP_SYNC_SHADOW( op->o_bd ) && |
|
op->o_msgid == SLAP_SYNC_UPDATE_MSGID ) { |
ldap_pvt_thread_rdwr_wunlock( &si->si_csn_rwlock ); |
ldap_pvt_thread_rdwr_wunlock( &si->si_csn_rwlock ); |
return SLAP_CB_CONTINUE; |
return SLAP_CB_CONTINUE; |
} |
} |
Line 1712 syncprov_op_response( Operation *op, Sla
|
Line 1641 syncprov_op_response( Operation *op, Sla
|
ldap_pvt_thread_rdwr_runlock( &si->si_csn_rwlock ); |
ldap_pvt_thread_rdwr_runlock( &si->si_csn_rwlock ); |
} |
} |
|
|
/* only update consumer ctx if this is a newer csn */ |
opc->sctxcsn.bv_len = maxcsn.bv_len; |
if ( csn_changed ) { |
opc->sctxcsn.bv_val = cbuf; |
opc->sctxcsn = maxcsn; |
|
} |
|
|
|
/* Handle any persistent searches */ |
/* Handle any persistent searches */ |
ldap_pvt_thread_mutex_lock( &si->si_ops_mutex ); |
ldap_pvt_thread_mutex_lock( &si->si_ops_mutex ); |
Line 1778 syncprov_op_compare( Operation *op, Slap
|
Line 1705 syncprov_op_compare( Operation *op, Slap
|
|
|
a.a_vals = si->si_ctxcsn; |
a.a_vals = si->si_ctxcsn; |
a.a_nvals = a.a_vals; |
a.a_nvals = a.a_vals; |
a.a_numvals = si->si_numcsns; |
|
|
|
rs->sr_err = access_allowed( op, &e, op->oq_compare.rs_ava->aa_desc, |
rs->sr_err = access_allowed( op, &e, op->oq_compare.rs_ava->aa_desc, |
&op->oq_compare.rs_ava->aa_value, ACL_COMPARE, NULL ); |
&op->oq_compare.rs_ava->aa_value, ACL_COMPARE, NULL ); |
Line 1978 syncprov_detach_op( Operation *op, synco
|
Line 1904 syncprov_detach_op( Operation *op, synco
|
op2->o_time = op->o_time; |
op2->o_time = op->o_time; |
op2->o_bd = on->on_info->oi_origdb; |
op2->o_bd = on->on_info->oi_origdb; |
op2->o_request = op->o_request; |
op2->o_request = op->o_request; |
op2->o_managedsait = op->o_managedsait; |
|
LDAP_SLIST_FIRST(&op2->o_extra)->oe_key = on; |
LDAP_SLIST_FIRST(&op2->o_extra)->oe_key = on; |
LDAP_SLIST_NEXT(LDAP_SLIST_FIRST(&op2->o_extra), oe_next) = NULL; |
LDAP_SLIST_NEXT(LDAP_SLIST_FIRST(&op2->o_extra), oe_next) = NULL; |
|
|
Line 2045 syncprov_search_response( Operation *op,
|
Line 1970 syncprov_search_response( Operation *op,
|
{ |
{ |
searchstate *ss = op->o_callback->sc_private; |
searchstate *ss = op->o_callback->sc_private; |
slap_overinst *on = ss->ss_on; |
slap_overinst *on = ss->ss_on; |
syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private; |
|
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 ) { |
Line 2111 syncprov_search_response( Operation *op,
|
Line 2035 syncprov_search_response( Operation *op,
|
rs->sr_ctrls = op->o_tmpalloc( sizeof(LDAPControl *)*2, |
rs->sr_ctrls = op->o_tmpalloc( sizeof(LDAPControl *)*2, |
op->o_tmpmemctx ); |
op->o_tmpmemctx ); |
rs->sr_ctrls[1] = NULL; |
rs->sr_ctrls[1] = NULL; |
/* If we're in delta-sync mode, always send a cookie */ |
rs->sr_err = syncprov_state_ctrl( op, rs, rs->sr_entry, |
if ( si->si_nopres && si->si_usehint && a ) { |
LDAP_SYNC_ADD, rs->sr_ctrls, 0, 0, NULL ); |
struct berval cookie; |
|
slap_compose_sync_cookie( op, &cookie, a->a_nvals, srs->sr_state.rid, srs->sr_state.sid ); |
|
rs->sr_err = syncprov_state_ctrl( op, rs, rs->sr_entry, |
|
LDAP_SYNC_ADD, rs->sr_ctrls, 0, 1, &cookie ); |
|
} else { |
|
rs->sr_err = syncprov_state_ctrl( op, rs, rs->sr_entry, |
|
LDAP_SYNC_ADD, rs->sr_ctrls, 0, 0, NULL ); |
|
} |
|
} 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; |
|
|
Line 2152 syncprov_search_response( Operation *op,
|
Line 2068 syncprov_search_response( Operation *op,
|
op->o_tmpfree( cookie.bv_val, op->o_tmpmemctx ); |
op->o_tmpfree( cookie.bv_val, op->o_tmpmemctx ); |
|
|
/* Detach this Op from frontend control */ |
/* Detach this Op from frontend control */ |
|
ldap_pvt_thread_mutex_lock( &ss->ss_so->s_mutex ); |
ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex ); |
ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex ); |
|
|
/* But not if this connection was closed along the way */ |
/* But not if this connection was closed along the way */ |
if ( op->o_abandon ) { |
if ( op->o_abandon ) { |
ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex ); |
ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex ); |
/* syncprov_ab_cleanup will free this syncop */ |
ldap_pvt_thread_mutex_unlock( &ss->ss_so->s_mutex ); |
|
syncprov_free_syncop( ss->ss_so ); |
return SLAPD_ABANDON; |
return SLAPD_ABANDON; |
|
|
} else { |
} else { |
ldap_pvt_thread_mutex_lock( &ss->ss_so->s_mutex ); |
|
/* Turn off the refreshing flag */ |
/* Turn off the refreshing flag */ |
ss->ss_so->s_flags ^= PS_IS_REFRESHING; |
ss->ss_so->s_flags ^= PS_IS_REFRESHING; |
|
|
Line 2172 syncprov_search_response( Operation *op,
|
Line 2089 syncprov_search_response( Operation *op,
|
/* If there are queued responses, fire them off */ |
/* If there are queued responses, fire them off */ |
if ( ss->ss_so->s_res ) |
if ( ss->ss_so->s_res ) |
syncprov_qstart( ss->ss_so ); |
syncprov_qstart( ss->ss_so ); |
ldap_pvt_thread_mutex_unlock( &ss->ss_so->s_mutex ); |
|
} |
} |
|
ldap_pvt_thread_mutex_unlock( &ss->ss_so->s_mutex ); |
|
|
return LDAP_SUCCESS; |
return LDAP_SUCCESS; |
} |
} |
Line 2204 syncprov_op_search( Operation *op, SlapR
|
Line 2121 syncprov_op_search( Operation *op, SlapR
|
} |
} |
|
|
srs = op->o_controls[slap_cids.sc_LDAPsync]; |
srs = op->o_controls[slap_cids.sc_LDAPsync]; |
|
op->o_managedsait = SLAP_CONTROL_NONCRITICAL; |
|
|
/* If this is a persistent search, set it up right away */ |
/* If this is a persistent search, set it up right away */ |
if ( op->o_sync_mode & SLAP_SYNC_PERSIST ) { |
if ( op->o_sync_mode & SLAP_SYNC_PERSIST ) { |
Line 2331 no_change: if ( !(op->o_sync_mode & SLA
|
Line 2249 no_change: if ( !(op->o_sync_mode & SLA
|
} |
} |
goto shortcut; |
goto shortcut; |
} |
} |
} else { |
|
/* consumer doesn't have the right number of CSNs */ |
|
changed = SS_CHANGED; |
|
} |
} |
/* Do we have a sessionlog for this search? */ |
/* Do we have a sessionlog for this search? */ |
sl=si->si_logs; |
sl=si->si_logs; |
Line 2362 no_change: if ( !(op->o_sync_mode & SLA
|
Line 2277 no_change: if ( !(op->o_sync_mode & SLA
|
send_ldap_error( op, rs, LDAP_SYNC_REFRESH_REQUIRED, "sync cookie is stale" ); |
send_ldap_error( op, rs, LDAP_SYNC_REFRESH_REQUIRED, "sync cookie is stale" ); |
return rs->sr_err; |
return rs->sr_err; |
} |
} |
if ( srs->sr_state.ctxcsn ) { |
|
ber_bvarray_free_x( srs->sr_state.ctxcsn, op->o_tmpmemctx ); |
|
srs->sr_state.ctxcsn = NULL; |
|
} |
|
if ( srs->sr_state.sids ) { |
|
slap_sl_free( srs->sr_state.sids, op->o_tmpmemctx ); |
|
srs->sr_state.sids = NULL; |
|
} |
|
srs->sr_state.numcsns = 0; |
|
} else { |
} else { |
gotstate = 1; |
gotstate = 1; |
/* If changed and doing Present lookup, send Present UUIDs */ |
/* If changed and doing Present lookup, send Present UUIDs */ |
Line 2485 syncprov_operational(
|
Line 2391 syncprov_operational(
|
} |
} |
|
|
if ( !ap ) { |
if ( !ap ) { |
if ( !(rs->sr_flags & REP_ENTRY_MODIFIABLE) ) { |
if ( !rs->sr_flags & REP_ENTRY_MODIFIABLE ) { |
Entry *e = entry_dup( rs->sr_entry ); |
rs->sr_entry = entry_dup( rs->sr_entry ); |
if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) { |
|
overlay_entry_release_ov( op, rs->sr_entry, 0, on ); |
|
rs->sr_flags ^= REP_ENTRY_MUSTRELEASE; |
|
} else if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) { |
|
entry_free( rs->sr_entry ); |
|
} |
|
rs->sr_entry = e; |
|
rs->sr_flags |= |
rs->sr_flags |= |
REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED; |
REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED; |
a = attr_find( rs->sr_entry->e_attrs, |
a = attr_find( rs->sr_entry->e_attrs, |
Line 2549 static ConfigOCs spocs[] = {
|
Line 2448 static ConfigOCs spocs[] = {
|
"NAME 'olcSyncProvConfig' " |
"NAME 'olcSyncProvConfig' " |
"DESC 'SyncRepl Provider configuration' " |
"DESC 'SyncRepl Provider configuration' " |
"SUP olcOverlayConfig " |
"SUP olcOverlayConfig " |
"MAY ( olcSpCheckpoint " |
"MAY ( olcSpCheckpoint $ olcSpSessionlog $ olcSpNoPresent ) )", |
"$ olcSpSessionlog " |
|
"$ olcSpNoPresent " |
|
"$ olcSpReloadHint " |
|
") )", |
|
Cft_Overlay, spcfg }, |
Cft_Overlay, spcfg }, |
{ NULL, 0, NULL } |
{ NULL, 0, NULL } |
}; |
}; |
Line 2572 sp_cf_gen(ConfigArgs *c)
|
Line 2467 sp_cf_gen(ConfigArgs *c)
|
struct berval bv; |
struct berval bv; |
bv.bv_len = snprintf( c->cr_msg, sizeof( c->cr_msg ), |
bv.bv_len = snprintf( c->cr_msg, sizeof( c->cr_msg ), |
"%d %d", si->si_chkops, si->si_chktime ); |
"%d %d", si->si_chkops, si->si_chktime ); |
if ( bv.bv_len >= sizeof( c->cr_msg ) ) { |
if ( bv.bv_len < 0 || bv.bv_len >= sizeof( c->cr_msg ) ) { |
rc = 1; |
rc = 1; |
} else { |
} else { |
bv.bv_val = c->cr_msg; |
bv.bv_val = c->cr_msg; |
Line 2766 syncprov_db_open(
|
Line 2661 syncprov_db_open(
|
si->si_sids = slap_parse_csn_sids( si->si_ctxcsn, a->a_numvals, NULL ); |
si->si_sids = slap_parse_csn_sids( si->si_ctxcsn, a->a_numvals, NULL ); |
} |
} |
overlay_entry_release_ov( op, e, 0, on ); |
overlay_entry_release_ov( op, e, 0, on ); |
if ( si->si_ctxcsn && !SLAP_DBCLEAN( be )) { |
if ( si->si_ctxcsn ) { |
op->o_req_dn = be->be_suffix[0]; |
op->o_req_dn = be->be_suffix[0]; |
op->o_req_ndn = be->be_nsuffix[0]; |
op->o_req_ndn = be->be_nsuffix[0]; |
op->ors_scope = LDAP_SCOPE_SUBTREE; |
op->ors_scope = LDAP_SCOPE_SUBTREE; |