version 1.53, 2004/12/10 00:35:34
|
version 1.54, 2004/12/10 00:50:16
|
Line 1
|
Line 1
|
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.52 2004/12/09 21:21:26 hyc Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.53 2004/12/10 00:35:34 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 1741 syncprov_op_search( Operation *op, SlapR
|
Line 1741 syncprov_op_search( Operation *op, SlapR
|
sop = ch_malloc( sizeof( syncops )); |
sop = ch_malloc( sizeof( syncops )); |
*sop = so; |
*sop = so; |
ldap_pvt_thread_mutex_init( &sop->s_mutex ); |
ldap_pvt_thread_mutex_init( &sop->s_mutex ); |
ldap_pvt_thread_mutex_lock( &si->si_ops_mutex ); |
|
sop->s_sid = srs->sr_state.sid; |
sop->s_sid = srs->sr_state.sid; |
sop->s_rid = srs->sr_state.rid; |
sop->s_rid = srs->sr_state.rid; |
sop->s_next = si->si_ops; |
|
sop->s_inuse = 1; |
sop->s_inuse = 1; |
si->si_ops = sop; |
|
ldap_pvt_thread_mutex_unlock( &si->si_ops_mutex ); |
|
} |
} |
|
|
/* snapshot the ctxcsn */ |
/* snapshot the ctxcsn */ |
Line 1760 syncprov_op_search( Operation *op, SlapR
|
Line 1756 syncprov_op_search( Operation *op, SlapR
|
/* If we have a cookie, handle the PRESENT lookups */ |
/* If we have a cookie, handle the PRESENT lookups */ |
if ( srs->sr_state.ctxcsn ) { |
if ( srs->sr_state.ctxcsn ) { |
sessionlog *sl; |
sessionlog *sl; |
|
int valid = 0; |
|
|
/* Is the CSN in a valid format? */ |
/* Is the CSN in a valid format? */ |
/* FIXME: should use csnValidate when that is implemented */ |
/* FIXME: should use csnValidate when that is implemented */ |
{ |
while (!valid) { |
char *ptr; |
char *ptr; |
struct berval timestamp; |
struct berval timestamp; |
slap_syntax_validate_func *validate; |
slap_syntax_validate_func *validate; |
AttributeDescription *ad = slap_schema.si_ad_modifyTimestamp; |
AttributeDescription *ad = slap_schema.si_ad_modifyTimestamp; |
|
|
if ( srs->sr_state.ctxcsn->bv_len >= LDAP_LUTIL_CSNSTR_BUFSIZE ) { |
if ( srs->sr_state.ctxcsn->bv_len >= LDAP_LUTIL_CSNSTR_BUFSIZE ) |
send_ldap_error( op, rs, LDAP_OTHER, "invalid sync cookie" ); |
break; |
return rs->sr_err; |
|
} |
|
ptr = strchr( srs->sr_state.ctxcsn->bv_val, '#' ); |
ptr = strchr( srs->sr_state.ctxcsn->bv_val, '#' ); |
if ( !ptr ) { |
if ( !ptr ) |
send_ldap_error( op, rs, LDAP_OTHER, "invalid sync cookie" ); |
break; |
return rs->sr_err; |
|
} |
|
timestamp.bv_val = srs->sr_state.ctxcsn->bv_val; |
timestamp.bv_val = srs->sr_state.ctxcsn->bv_val; |
timestamp.bv_len = ptr - timestamp.bv_val; |
timestamp.bv_len = ptr - timestamp.bv_val; |
validate = ad->ad_type->sat_syntax->ssyn_validate; |
validate = ad->ad_type->sat_syntax->ssyn_validate; |
if ( validate( ad->ad_type->sat_syntax, ×tamp )) { |
if ( validate( ad->ad_type->sat_syntax, ×tamp )) |
send_ldap_error( op, rs, LDAP_OTHER, "invalid sync cookie" ); |
break; |
return rs->sr_err; |
valid = 1; |
} |
} |
|
if ( !valid ) { |
|
if ( sop ) ch_free( sop ); |
|
send_ldap_error( op, rs, LDAP_OTHER, "invalid sync cookie" ); |
|
return rs->sr_err; |
} |
} |
/* If just Refreshing and nothing has changed, shortcut it */ |
/* If just Refreshing and nothing has changed, shortcut it */ |
if ( bvmatch( srs->sr_state.ctxcsn, &ctxcsn )) { |
if ( bvmatch( srs->sr_state.ctxcsn, &ctxcsn )) { |
Line 1843 shortcut:
|
Line 1840 shortcut:
|
*/ |
*/ |
if ( sop ) { |
if ( sop ) { |
sop->s_filterstr= op->ors_filterstr; |
sop->s_filterstr= op->ors_filterstr; |
|
|
|
/* insert record of psearch now */ |
|
ldap_pvt_thread_mutex_lock( &si->si_ops_mutex ); |
|
sop->s_next = si->si_ops; |
|
si->si_ops = sop; |
|
ldap_pvt_thread_mutex_unlock( &si->si_ops_mutex ); |
} |
} |
|
|
fand = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx ); |
fand = op->o_tmpalloc( sizeof(Filter), op->o_tmpmemctx ); |