version 1.189, 2007/05/19 12:12:24
|
version 1.200, 2007/09/24 03:02:32
|
Line 1
|
Line 1
|
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.188 2007/05/18 21:54:27 hallvard Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.199 2007/09/23 23:31:24 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 585 syncprov_findcsn( Operation *op, find_cs
|
Line 585 syncprov_findcsn( Operation *op, find_cs
|
char cbuf[LDAP_LUTIL_CSNSTR_BUFSIZE]; |
char cbuf[LDAP_LUTIL_CSNSTR_BUFSIZE]; |
struct berval maxcsn; |
struct berval maxcsn; |
Filter cf; |
Filter cf; |
#ifdef LDAP_COMP_MATCH |
AttributeAssertion eq = ATTRIBUTEASSERTION_INIT; |
AttributeAssertion eq = { NULL, BER_BVNULL, NULL }; |
|
#else |
|
AttributeAssertion eq = { NULL, BER_BVNULL }; |
|
#endif |
|
fpres_cookie pcookie; |
fpres_cookie pcookie; |
sync_control *srs = NULL; |
sync_control *srs = NULL; |
struct slap_limits_set fc_limits; |
struct slap_limits_set fc_limits; |
Line 659 again:
|
Line 655 again:
|
} else { |
} else { |
cf.f_choice = LDAP_FILTER_LE; |
cf.f_choice = LDAP_FILTER_LE; |
fop.ors_limit = &fc_limits; |
fop.ors_limit = &fc_limits; |
|
memset( &fc_limits, 0, sizeof( fc_limits )); |
fc_limits.lms_s_unchecked = 1; |
fc_limits.lms_s_unchecked = 1; |
fop.ors_filterstr.bv_len = sprintf( buf, "(entryCSN<=%s)", |
fop.ors_filterstr.bv_len = sprintf( buf, "(entryCSN<=%s)", |
cf.f_av_value.bv_val ); |
cf.f_av_value.bv_val ); |
Line 1290 syncprov_checkpoint( Operation *op, Slap
|
Line 1287 syncprov_checkpoint( Operation *op, Slap
|
SlapReply rsm = { 0 }; |
SlapReply rsm = { 0 }; |
slap_callback cb = {0}; |
slap_callback cb = {0}; |
|
|
|
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; |
Line 1482 syncprov_playlog( Operation *op, SlapRep
|
Line 1480 syncprov_playlog( Operation *op, SlapRep
|
SlapReply frs = { REP_RESULT }; |
SlapReply frs = { REP_RESULT }; |
int rc; |
int rc; |
Filter mf, af; |
Filter mf, af; |
#ifdef LDAP_COMP_MATCH |
AttributeAssertion eq = ATTRIBUTEASSERTION_INIT; |
AttributeAssertion eq = { NULL, BER_BVNULL, NULL }; |
|
#else |
|
AttributeAssertion eq; |
|
#endif |
|
slap_callback cb = {0}; |
slap_callback cb = {0}; |
|
|
fop = *op; |
fop = *op; |
Line 1686 syncprov_op_compare( Operation *op, Slap
|
Line 1680 syncprov_op_compare( Operation *op, Slap
|
|
|
rs->sr_err = LDAP_COMPARE_FALSE; |
rs->sr_err = LDAP_COMPARE_FALSE; |
|
|
if ( value_find_ex( op->oq_compare.rs_ava->aa_desc, |
if ( attr_valfind( &a, |
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH | |
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH | |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, |
a.a_nvals, &op->oq_compare.rs_ava->aa_value, op->o_tmpmemctx ) == 0 ) |
&op->oq_compare.rs_ava->aa_value, NULL, op->o_tmpmemctx ) == 0 ) |
{ |
{ |
rs->sr_err = LDAP_COMPARE_TRUE; |
rs->sr_err = LDAP_COMPARE_TRUE; |
} |
} |
Line 2307 syncprov_operational(
|
Line 2301 syncprov_operational(
|
a = attr_find( rs->sr_entry->e_attrs, |
a = attr_find( rs->sr_entry->e_attrs, |
slap_schema.si_ad_contextCSN ); |
slap_schema.si_ad_contextCSN ); |
} |
} |
free( a->a_vals ); |
if ( a->a_nvals != a->a_vals ) { |
|
ber_bvarray_free( a->a_nvals ); |
|
} |
|
a->a_nvals = NULL; |
|
ber_bvarray_free( a->a_vals ); |
|
a->a_vals = NULL; |
|
a->a_numvals = 0; |
} |
} |
ber_bvarray_dup_x( &a->a_vals, si->si_ctxcsn, NULL ); |
attr_valadd( a, si->si_ctxcsn, si->si_ctxcsn, si->si_numcsns ); |
a->a_nvals = a->a_vals; |
|
} |
} |
ldap_pvt_thread_rdwr_runlock( &si->si_csn_rwlock ); |
ldap_pvt_thread_rdwr_runlock( &si->si_csn_rwlock ); |
} |
} |
Line 2369 sp_cf_gen(ConfigArgs *c)
|
Line 2368 sp_cf_gen(ConfigArgs *c)
|
case SP_CHKPT: |
case SP_CHKPT: |
if ( si->si_chkops || si->si_chktime ) { |
if ( si->si_chkops || si->si_chktime ) { |
struct berval bv; |
struct berval bv; |
bv.bv_len = sprintf( c->msg, "%d %d", |
bv.bv_len = sprintf( c->cr_msg, "%d %d", |
si->si_chkops, si->si_chktime ); |
si->si_chkops, si->si_chktime ); |
bv.bv_val = c->msg; |
bv.bv_val = c->cr_msg; |
value_add_one( &c->rvalue_vals, &bv ); |
value_add_one( &c->rvalue_vals, &bv ); |
} else { |
} else { |
rc = 1; |
rc = 1; |
Line 2430 sp_cf_gen(ConfigArgs *c)
|
Line 2429 sp_cf_gen(ConfigArgs *c)
|
switch ( c->type ) { |
switch ( c->type ) { |
case SP_CHKPT: |
case SP_CHKPT: |
if ( lutil_atoi( &si->si_chkops, c->argv[1] ) != 0 ) { |
if ( lutil_atoi( &si->si_chkops, c->argv[1] ) != 0 ) { |
snprintf( c->msg, sizeof( c->msg ), "%s unable to parse checkpoint ops # \"%s\"", |
snprintf( c->cr_msg, sizeof( c->cr_msg ), "%s unable to parse checkpoint ops # \"%s\"", |
c->argv[0], c->argv[1] ); |
c->argv[0], c->argv[1] ); |
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, |
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, |
"%s: %s\n", c->log, c->msg, 0 ); |
"%s: %s\n", c->log, c->cr_msg, 0 ); |
return ARG_BAD_CONF; |
return ARG_BAD_CONF; |
} |
} |
if ( si->si_chkops <= 0 ) { |
if ( si->si_chkops <= 0 ) { |
snprintf( c->msg, sizeof( c->msg ), "%s invalid checkpoint ops # \"%d\"", |
snprintf( c->cr_msg, sizeof( c->cr_msg ), "%s invalid checkpoint ops # \"%d\"", |
c->argv[0], si->si_chkops ); |
c->argv[0], si->si_chkops ); |
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, |
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, |
"%s: %s\n", c->log, c->msg, 0 ); |
"%s: %s\n", c->log, c->cr_msg, 0 ); |
return ARG_BAD_CONF; |
return ARG_BAD_CONF; |
} |
} |
if ( lutil_atoi( &si->si_chktime, c->argv[2] ) != 0 ) { |
if ( lutil_atoi( &si->si_chktime, c->argv[2] ) != 0 ) { |
snprintf( c->msg, sizeof( c->msg ), "%s unable to parse checkpoint time \"%s\"", |
snprintf( c->cr_msg, sizeof( c->cr_msg ), "%s unable to parse checkpoint time \"%s\"", |
c->argv[0], c->argv[1] ); |
c->argv[0], c->argv[1] ); |
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, |
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, |
"%s: %s\n", c->log, c->msg, 0 ); |
"%s: %s\n", c->log, c->cr_msg, 0 ); |
return ARG_BAD_CONF; |
return ARG_BAD_CONF; |
} |
} |
if ( si->si_chktime <= 0 ) { |
if ( si->si_chktime <= 0 ) { |
snprintf( c->msg, sizeof( c->msg ), "%s invalid checkpoint time \"%d\"", |
snprintf( c->cr_msg, sizeof( c->cr_msg ), "%s invalid checkpoint time \"%d\"", |
c->argv[0], si->si_chkops ); |
c->argv[0], si->si_chkops ); |
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, |
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, |
"%s: %s\n", c->log, c->msg, 0 ); |
"%s: %s\n", c->log, c->cr_msg, 0 ); |
return ARG_BAD_CONF; |
return ARG_BAD_CONF; |
} |
} |
si->si_chktime *= 60; |
si->si_chktime *= 60; |
Line 2464 sp_cf_gen(ConfigArgs *c)
|
Line 2463 sp_cf_gen(ConfigArgs *c)
|
int size = c->value_int; |
int size = c->value_int; |
|
|
if ( size < 0 ) { |
if ( size < 0 ) { |
snprintf( c->msg, sizeof( c->msg ), "%s size %d is negative", |
snprintf( c->cr_msg, sizeof( c->cr_msg ), "%s size %d is negative", |
c->argv[0], size ); |
c->argv[0], size ); |
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, |
Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, |
"%s: %s\n", c->log, c->msg, 0 ); |
"%s: %s\n", c->log, c->cr_msg, 0 ); |
return ARG_BAD_CONF; |
return ARG_BAD_CONF; |
} |
} |
sl = si->si_logs; |
sl = si->si_logs; |
Line 2511 syncprov_db_otask(
|
Line 2510 syncprov_db_otask(
|
*/ |
*/ |
static int |
static int |
syncprov_db_open( |
syncprov_db_open( |
BackendDB *be |
BackendDB *be, |
|
ConfigReply *cr |
) |
) |
{ |
{ |
slap_overinst *on = (slap_overinst *) be->bd_info; |
slap_overinst *on = (slap_overinst *) be->bd_info; |
Line 2555 syncprov_db_open(
|
Line 2555 syncprov_db_open(
|
|
|
a = attr_find( e->e_attrs, slap_schema.si_ad_contextCSN ); |
a = attr_find( e->e_attrs, slap_schema.si_ad_contextCSN ); |
if ( a ) { |
if ( a ) { |
int i; |
|
ber_bvarray_dup_x( &si->si_ctxcsn, a->a_vals, NULL ); |
ber_bvarray_dup_x( &si->si_ctxcsn, a->a_vals, NULL ); |
for ( i = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ ); |
si->si_numcsns = a->a_numvals; |
si->si_numcsns = i; |
si->si_sids = slap_parse_csn_sids( si->si_ctxcsn, a->a_numvals, NULL ); |
si->si_sids = slap_parse_csn_sids( si->si_ctxcsn, i, NULL ); |
|
} |
} |
overlay_entry_release_ov( op, e, 0, on ); |
overlay_entry_release_ov( op, e, 0, on ); |
if ( si->si_ctxcsn ) { |
if ( si->si_ctxcsn ) { |
Line 2604 out:
|
Line 2602 out:
|
*/ |
*/ |
static int |
static int |
syncprov_db_close( |
syncprov_db_close( |
BackendDB *be |
BackendDB *be, |
|
ConfigReply *cr |
) |
) |
{ |
{ |
slap_overinst *on = (slap_overinst *) be->bd_info; |
slap_overinst *on = (slap_overinst *) be->bd_info; |
Line 2614 syncprov_db_close(
|
Line 2613 syncprov_db_close(
|
return 0; |
return 0; |
} |
} |
if ( si->si_numops ) { |
if ( si->si_numops ) { |
Connection conn; |
Connection conn = {0}; |
OperationBuffer opbuf; |
OperationBuffer opbuf; |
Operation *op; |
Operation *op; |
SlapReply rs = {REP_RESULT}; |
SlapReply rs = {REP_RESULT}; |
Line 2634 syncprov_db_close(
|
Line 2633 syncprov_db_close(
|
|
|
static int |
static int |
syncprov_db_init( |
syncprov_db_init( |
BackendDB *be |
BackendDB *be, |
|
ConfigReply *cr |
) |
) |
{ |
{ |
slap_overinst *on = (slap_overinst *)be->bd_info; |
slap_overinst *on = (slap_overinst *)be->bd_info; |
Line 2666 syncprov_db_init(
|
Line 2666 syncprov_db_init(
|
|
|
static int |
static int |
syncprov_db_destroy( |
syncprov_db_destroy( |
BackendDB *be |
BackendDB *be, |
|
ConfigReply *cr |
) |
) |
{ |
{ |
slap_overinst *on = (slap_overinst *)be->bd_info; |
slap_overinst *on = (slap_overinst *)be->bd_info; |
Line 2785 static int syncprov_parseCtrl (
|
Line 2786 static int syncprov_parseCtrl (
|
sr->sr_rhint = rhint; |
sr->sr_rhint = rhint; |
if (!BER_BVISNULL(&cookie)) { |
if (!BER_BVISNULL(&cookie)) { |
ber_dupbv_x( &sr->sr_state.octet_str, &cookie, op->o_tmpmemctx ); |
ber_dupbv_x( &sr->sr_state.octet_str, &cookie, op->o_tmpmemctx ); |
slap_parse_sync_cookie( &sr->sr_state, op->o_tmpmemctx ); |
if ( slap_parse_sync_cookie( &sr->sr_state, op->o_tmpmemctx ) || |
if ( sr->sr_state.rid == -1 ) { |
sr->sr_state.rid == -1 ) { |
rs->sr_text = "Sync control : cookie parsing error"; |
rs->sr_text = "Sync control : cookie parsing error"; |
return LDAP_PROTOCOL_ERROR; |
return LDAP_PROTOCOL_ERROR; |
} |
} |