From: Howard Chu Date: Thu, 11 May 2006 10:46:44 +0000 (+0000) Subject: ITS#4534 propagate CSN for delete syncID sets X-Git-Tag: OPENLDAP_REL_ENG_2_4_1ALPHA~2^2~46 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=837e9466b8786ad8eb88b665f8349238500bdc4b;p=openldap ITS#4534 propagate CSN for delete syncID sets --- diff --git a/servers/slapd/overlays/syncprov.c b/servers/slapd/overlays/syncprov.c index 798924fb1f..3fe92a3e2b 100644 --- a/servers/slapd/overlays/syncprov.c +++ b/servers/slapd/overlays/syncprov.c @@ -1320,12 +1320,14 @@ playlog_cb( Operation *op, SlapReply *rs ) /* enter with sl->sl_mutex locked, release before returning */ static void 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; slog_entry *se; int i, j, ndel, num, nmods, mmods; + char cbuf[LDAP_LUTIL_CSNSTR_BUFSIZE]; BerVarray uuids; + struct berval delcsn; if ( !sl->sl_num ) { ldap_pvt_thread_mutex_unlock( &sl->sl_mutex ); @@ -1338,19 +1340,23 @@ syncprov_playlog( Operation *op, SlapReply *rs, sessionlog *sl, uuids = op->o_tmpalloc( (num+1) * sizeof( struct berval ) + num * UUID_LEN, op->o_tmpmemctx ); - 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 * and everything else at the end. Do this first so we can * unlock the list mutex. */ 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 ( se->se_tag == LDAP_REQ_DELETE ) { j = i; i++; + AC_MEMCPY( cbuf, se->se_csn.bv_val, se->se_csn.bv_len ); + delcsn.bv_len = se->se_csn.bv_len; } else { nmods++; j = num - nmods; @@ -1442,9 +1448,14 @@ syncprov_playlog( Operation *op, SlapReply *rs, sessionlog *sl, fop.o_bd->bd_info = (BackendInfo *)on; } if ( ndel ) { + struct berval cookie; + + slap_compose_sync_cookie( op, &cookie, &delcsn, srs->sr_state.rid ); 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 @@ -1973,7 +1984,7 @@ syncprov_op_search( Operation *op, SlapReply *rs ) if ( ber_bvcmp( &srs->sr_state.ctxcsn, &sl->sl_mincsn ) >= 0 ) { do_present = 0; /* mutex is unlocked in playlog */ - syncprov_playlog( op, rs, sl, &srs->sr_state.ctxcsn, &ctxcsn ); + syncprov_playlog( op, rs, sl, srs, &ctxcsn ); } else { ldap_pvt_thread_mutex_unlock( &sl->sl_mutex ); } diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 19c31ec6e5..de322be98f 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -91,7 +91,7 @@ typedef struct syncinfo_s { static int syncuuid_cmp( const void *, const void * ); static void avl_ber_bvfree( void * ); -static void syncrepl_del_nonpresent( Operation *, syncinfo_t *, BerVarray ); +static void syncrepl_del_nonpresent( Operation *, syncinfo_t *, BerVarray, struct berval * ); static int syncrepl_message_to_op( syncinfo_t *, Operation *, LDAPMessage * ); static int syncrepl_message_to_entry( @@ -824,7 +824,7 @@ do_syncrep2( if ( refreshDeletes == 0 && match < 0 && err == LDAP_SUCCESS ) { - syncrepl_del_nonpresent( op, si, NULL ); + syncrepl_del_nonpresent( op, si, NULL, NULL ); } else { avl_free( si->si_presentlist, avl_ber_bvfree ); si->si_presentlist = NULL; @@ -916,7 +916,8 @@ do_syncrep2( ber_scanf( ber, "[W]", &syncUUIDs ); ber_scanf( ber, /*"{"*/ "}" ); if ( refreshDeletes ) { - syncrepl_del_nonpresent( op, si, syncUUIDs ); + syncrepl_del_nonpresent( op, si, syncUUIDs, + &syncCookie.ctxcsn ); ber_bvarray_free_x( syncUUIDs, op->o_tmpmemctx ); } else { for ( i = 0; !BER_BVISNULL( &syncUUIDs[i] ); i++ ) { @@ -959,7 +960,7 @@ do_syncrep2( if ( si->si_refreshPresent == 1 ) { if ( match < 0 ) { - syncrepl_del_nonpresent( op, si, NULL ); + syncrepl_del_nonpresent( op, si, NULL, NULL ); } } @@ -2022,7 +2023,8 @@ static void syncrepl_del_nonpresent( Operation *op, syncinfo_t *si, - BerVarray uuids ) + BerVarray uuids, + struct berval *cookiecsn ) { Backend* be = op->o_bd; slap_callback cb = { NULL }; @@ -2034,6 +2036,7 @@ syncrepl_del_nonpresent( AttributeName an[2]; struct berval pdn = BER_BVNULL; + struct berval csn; op->o_req_dn = si->si_base; op->o_req_ndn = si->si_base; @@ -2100,7 +2103,12 @@ syncrepl_del_nonpresent( if ( !LDAP_LIST_EMPTY( &si->si_nonpresentlist ) ) { - slap_queue_csn( op, &si->si_syncCookie.ctxcsn ); + if ( cookiecsn && !BER_BVISNULL( cookiecsn )) + csn = *cookiecsn; + else + csn = si->si_syncCookie.ctxcsn; + + slap_queue_csn( op, &csn ); np_list = LDAP_LIST_FIRST( &si->si_nonpresentlist ); while ( np_list != NULL ) {