version 1.147, 2006/04/02 21:49:57
|
version 1.147.2.1, 2006/05/15 17:04:44
|
Line 1
|
Line 1
|
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.146 2006/03/31 08:45:23 hyc Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/syncprov.c,v 1.150 2006/05/11 08:46:44 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 1320 playlog_cb( Operation *op, SlapReply *rs
|
Line 1320 playlog_cb( Operation *op, SlapReply *rs
|
/* enter with sl->sl_mutex locked, release before returning */ |
/* enter with sl->sl_mutex locked, release before returning */ |
static void |
static void |
syncprov_playlog( Operation *op, SlapReply *rs, sessionlog *sl, |
syncprov_playlog( Operation *op, SlapReply *rs, sessionlog *sl, |
struct berval *oldcsn, struct berval *ctxcsn ) |
sync_control *srs, struct berval *ctxcsn ) |
{ |
{ |
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; |
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; |
slog_entry *se; |
slog_entry *se; |
int i, j, ndel, num, nmods, mmods; |
int i, j, ndel, num, nmods, mmods; |
|
char cbuf[LDAP_LUTIL_CSNSTR_BUFSIZE]; |
BerVarray uuids; |
BerVarray uuids; |
|
struct berval delcsn; |
|
|
if ( !sl->sl_num ) { |
if ( !sl->sl_num ) { |
ldap_pvt_thread_mutex_unlock( &sl->sl_mutex ); |
ldap_pvt_thread_mutex_unlock( &sl->sl_mutex ); |
Line 1338 syncprov_playlog( Operation *op, SlapRep
|
Line 1340 syncprov_playlog( Operation *op, SlapRep
|
|
|
uuids = op->o_tmpalloc( (num+1) * sizeof( struct berval ) + |
uuids = op->o_tmpalloc( (num+1) * sizeof( struct berval ) + |
num * UUID_LEN, op->o_tmpmemctx ); |
num * UUID_LEN, op->o_tmpmemctx ); |
|
|
uuids[0].bv_val = (char *)(uuids + num + 1); |
uuids[0].bv_val = (char *)(uuids + num + 1); |
|
|
|
delcsn.bv_len = 0; |
|
delcsn.bv_val = cbuf; |
|
|
/* Make a copy of the relevant UUIDs. Put the Deletes up front |
/* Make a copy of the relevant UUIDs. Put the Deletes up front |
* and everything else at the end. Do this first so we can |
* and everything else at the end. Do this first so we can |
* unlock the list mutex. |
* unlock the list mutex. |
*/ |
*/ |
for ( se=sl->sl_head; se; se=se->se_next ) { |
for ( se=sl->sl_head; se; se=se->se_next ) { |
if ( ber_bvcmp( &se->se_csn, oldcsn ) < 0 ) continue; |
if ( ber_bvcmp( &se->se_csn, &srs->sr_state.ctxcsn ) <= 0 ) continue; |
if ( ber_bvcmp( &se->se_csn, ctxcsn ) > 0 ) break; |
if ( ber_bvcmp( &se->se_csn, ctxcsn ) > 0 ) break; |
if ( se->se_tag == LDAP_REQ_DELETE ) { |
if ( se->se_tag == LDAP_REQ_DELETE ) { |
j = i; |
j = i; |
i++; |
i++; |
|
AC_MEMCPY( cbuf, se->se_csn.bv_val, se->se_csn.bv_len ); |
|
delcsn.bv_len = se->se_csn.bv_len; |
} else { |
} else { |
nmods++; |
nmods++; |
j = num - nmods; |
j = num - nmods; |
Line 1442 syncprov_playlog( Operation *op, SlapRep
|
Line 1448 syncprov_playlog( Operation *op, SlapRep
|
fop.o_bd->bd_info = (BackendInfo *)on; |
fop.o_bd->bd_info = (BackendInfo *)on; |
} |
} |
if ( ndel ) { |
if ( ndel ) { |
|
struct berval cookie; |
|
|
|
slap_compose_sync_cookie( op, &cookie, &delcsn, srs->sr_state.rid ); |
uuids[ndel].bv_val = NULL; |
uuids[ndel].bv_val = NULL; |
syncprov_sendinfo( op, rs, LDAP_TAG_SYNC_ID_SET, NULL, 0, uuids, 1 ); |
syncprov_sendinfo( op, rs, LDAP_TAG_SYNC_ID_SET, &cookie, 0, uuids, 1 ); |
|
op->o_tmpfree( cookie.bv_val, op->o_tmpmemctx ); |
} |
} |
|
op->o_tmpfree( uuids, op->o_tmpmemctx ); |
} |
} |
|
|
static int |
static int |
Line 1811 syncprov_search_response( Operation *op,
|
Line 1822 syncprov_search_response( Operation *op,
|
} |
} |
if ( a ) { |
if ( a ) { |
/* Make sure entry is less than the snapshot'd contextCSN */ |
/* Make sure entry is less than the snapshot'd contextCSN */ |
if ( ber_bvcmp( &a->a_nvals[0], &ss->ss_ctxcsn ) > 0 ) |
if ( ber_bvcmp( &a->a_nvals[0], &ss->ss_ctxcsn ) > 0 ) { |
|
Debug( LDAP_DEBUG_SYNC, "Entry %s CSN %s greater than snapshot %s\n", |
|
rs->sr_entry->e_name.bv_val, |
|
a->a_nvals[0].bv_val, |
|
ss->ss_ctxcsn.bv_val ); |
return LDAP_SUCCESS; |
return LDAP_SUCCESS; |
|
} |
|
|
/* Don't send the ctx entry twice */ |
/* Don't send the ctx entry twice */ |
if ( !BER_BVISNULL( &srs->sr_state.ctxcsn ) && |
if ( !BER_BVISNULL( &srs->sr_state.ctxcsn ) && |
bvmatch( &a->a_nvals[0], &srs->sr_state.ctxcsn ) ) |
bvmatch( &a->a_nvals[0], &srs->sr_state.ctxcsn ) ) { |
|
Debug( LDAP_DEBUG_SYNC, "Entry %s CSN %s matches ctx %s\n", |
|
rs->sr_entry->e_name.bv_val, |
|
a->a_nvals[0].bv_val, |
|
srs->sr_state.ctxcsn.bv_val ); |
return LDAP_SUCCESS; |
return LDAP_SUCCESS; |
|
} |
} |
} |
rs->sr_ctrls = op->o_tmpalloc( sizeof(LDAPControl *)*2, |
rs->sr_ctrls = op->o_tmpalloc( sizeof(LDAPControl *)*2, |
op->o_tmpmemctx ); |
op->o_tmpmemctx ); |
Line 1963 syncprov_op_search( Operation *op, SlapR
|
Line 1984 syncprov_op_search( Operation *op, SlapR
|
if ( ber_bvcmp( &srs->sr_state.ctxcsn, &sl->sl_mincsn ) >= 0 ) { |
if ( ber_bvcmp( &srs->sr_state.ctxcsn, &sl->sl_mincsn ) >= 0 ) { |
do_present = 0; |
do_present = 0; |
/* mutex is unlocked in playlog */ |
/* mutex is unlocked in playlog */ |
syncprov_playlog( op, rs, sl, &srs->sr_state.ctxcsn, &ctxcsn ); |
syncprov_playlog( op, rs, sl, srs, &ctxcsn ); |
} else { |
} else { |
ldap_pvt_thread_mutex_unlock( &sl->sl_mutex ); |
ldap_pvt_thread_mutex_unlock( &sl->sl_mutex ); |
} |
} |