static int nonpresent_callback( struct slap_op *, struct slap_rep * );
static int null_callback( struct slap_op *, struct slap_rep * );
+static int si_refreshDelete = 0;
+static int si_refreshPresent = 0;
+
static AttributeDescription *sync_descs[4];
struct runqueue_s syncrepl_rq;
}
si->si_attrs = tmp;
+
+ for ( n = 0; si->si_exattrs[ n ] != NULL; n++ ) /* empty */;
+ if ( n ) {
+ /* Delete Attributes from exattrs list */
+ for ( i = 0; sync_descs[i] != NULL; i++ ) {
+ for ( j = 0; si->si_exattrs[j] != NULL; j++ ) {
+ if ( strcmp( si->si_exattrs[j], sync_descs[i]->ad_cname.bv_val )
+ == 0 )
+ {
+ ch_free( si->si_exattrs[j] );
+ for ( k = j; si->si_exattrs[k] != NULL; k++ ) {
+ si->si_exattrs[k] = si->si_exattrs[k+1];
+ }
+ }
+ }
+ }
+ }
}
static int
}
}
+ slap_sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
+
return rc;
}
case LDAP_RES_SEARCH_REFERENCE:
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR,
- "do_syncrep2 : reference received\n", 0, 0, 0 );
+ "do_syncrep2: reference received error\n", 0, 0, 0 );
#else
Debug( LDAP_DEBUG_ANY,
- "do_syncrep2 : reference received\n", 0, 0, 0 );
+ "do_syncrep2: reference received error\n", 0, 0, 0 );
#endif
break;
rc = ldap_parse_intermediate( si->si_ld, msg,
&retoid, &retdata, NULL, 0 );
if ( !rc && !strcmp( retoid, LDAP_SYNC_INFO ) ) {
- int si_refreshDelete = 0;
- int si_refreshPresent = 0;
ber_init2( ber, retdata, LBER_USE_DER );
switch ( si_tag = ber_peek_tag( ber, &len )) {
case LDAP_TAG_SYNC_REFRESH_DELETE:
si_refreshDelete = 1;
case LDAP_TAG_SYNC_REFRESH_PRESENT:
+ si_refreshPresent = 1;
si_refreshPresent = 1;
ber_scanf( ber, "t{", &tag );
if ( ber_peek_tag( ber, &len ) == LDAP_TAG_SYNC_COOKIE )
for ( i = 0; syncUUIDs[i].bv_val; i++ ) {
struct berval *syncuuid_bv;
syncuuid_bv = ber_dupbv( NULL, &syncUUIDs[i] );
+ slap_sl_free( syncUUIDs[i].bv_val,op->o_tmpmemctx );
avl_insert( &si->si_presentlist,
(caddr_t) syncuuid_bv,
syncuuid_cmp, avl_dup_error );
}
- ber_memfree_x( syncUUIDs, op->o_tmpmemctx );
+ slap_sl_free( syncUUIDs, op->o_tmpmemctx );
break;
default:
#ifdef NEW_LOGGING
int dostop = 0;
ber_socket_t s;
int i, defer = 1;
+ Backend *be;
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, DETAIL1, "do_syncrepl\n", 0, 0, 0 );
op.o_dn = si->si_updatedn;
op.o_ndn = si->si_updatedn;
op.o_managedsait = 1;
- op.o_bd = si->si_be;
+ op.o_bd = be = si->si_be;
op.o_sync_state.ctxcsn = NULL;
op.o_sync_state.sid = -1;
/* Establish session, do search */
if ( !si->si_ld ) {
first = 1;
+ si_refreshDelete = 0;
+ si_refreshPresent = 0;
rc = do_syncrep1( &op, si );
}
*/
if ( rc == LDAP_SUCCESS ) {
if ( first ) {
- rc = connection_client_setup( s, do_syncrepl,
- arg );
+ rc = connection_client_setup( s, do_syncrepl, arg );
} else {
connection_client_enable( s );
}
if ( !si->si_retrynum || si->si_retrynum[i] == -2 ) {
ldap_pvt_runqueue_remove( &syncrepl_rq, rtask );
+ LDAP_STAILQ_REMOVE( &be->be_syncinfo, si, syncinfo_s, si_next );
+ syncinfo_free( si );
} else if ( si->si_retrynum[i] >= -1 ) {
if ( si->si_retrynum[i] > 0 )
si->si_retrynum[i]--;
if ( mod->sml_desc->ad_type->sat_flags & SLAP_AT_DYNAMIC ) {
*modtail = mod->sml_next;
slap_mod_free( &mod->sml_mod, 0 );
- free( mod );
+ ch_free( mod );
+ } else {
+ modtail = &mod->sml_next;
+ }
+ }
+
+ /* Strip out attrs in exattrs list */
+ for ( modtail = modlist; *modtail ; ) {
+ mod = *modtail;
+ if ( ldap_charray_inlist( si->si_exattrs,
+ mod->sml_desc->ad_type->sat_cname.bv_val )) {
+ *modtail = mod->sml_next;
+ slap_mod_free( &mod->sml_mod, 0 );
+ ch_free( mod );
} else {
modtail = &mod->sml_next;
}
if (( syncstate == LDAP_SYNC_PRESENT || syncstate == LDAP_SYNC_ADD ))
{
- syncuuid_bv = ber_dupbv( NULL, syncUUID );
- avl_insert( &si->si_presentlist, (caddr_t) syncuuid_bv,
- syncuuid_cmp, avl_dup_error );
+ if (!si_refreshPresent) {
+ syncuuid_bv = ber_dupbv( NULL, syncUUID );
+ avl_insert( &si->si_presentlist, (caddr_t) syncuuid_bv,
+ syncuuid_cmp, avl_dup_error );
+ }
}
if ( syncstate == LDAP_SYNC_PRESENT ) {
done :
if ( syncUUID_strrep.bv_val ) {
- ber_memfree_x( syncUUID_strrep.bv_val, op->o_tmpmemctx );
+ slap_sl_free( syncUUID_strrep.bv_val, op->o_tmpmemctx );
}
if ( si->si_syncUUID_ndn.bv_val ) {
- ber_memfree_x( si->si_syncUUID_ndn.bv_val, op->o_tmpmemctx );
+ ch_free( si->si_syncUUID_ndn.bv_val );
+ si->si_syncUUID_ndn.bv_val = NULL;
}
return ret;
}
Modifications *mlnext;
Modifications *mod;
Modifications *modlist = NULL;
- Modifications **modtail = &modlist;
+ Modifications **modtail;
Attribute *attr;
struct berval pdn = BER_BVNULL;
rc = op->o_bd->be_delete( op, &rs_delete );
if ( rs_delete.sr_err == LDAP_NOT_ALLOWED_ON_NONLEAF ) {
+ modtail = &modlist;
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
mod->sml_op = LDAP_MOD_REPLACE;
mod->sml_desc = slap_schema.si_ad_objectClass;
*modtail = mod;
modtail = &mod->sml_next;
- if ( scbva[0].bv_val ) ch_free( scbva[0].bv_val );
- ber_dupbv( &scbva[0], &si->si_syncCookie.octet_str[0] );
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
mod->sml_op = LDAP_MOD_REPLACE;
- mod->sml_desc = slap_schema.si_ad_syncreplCookie;
+ mod->sml_desc = slap_schema.si_ad_subtreeSpecification;
mod->sml_type = mod->sml_desc->ad_cname;
- mod->sml_values = scbva;
+ mod->sml_values = ssbva;
*modtail = mod;
modtail = &mod->sml_next;
+ /* Keep this last, so we can avoid touching the previous
+ * attributes unnecessarily.
+ */
+ if ( scbva[0].bv_val ) ch_free( scbva[0].bv_val );
+ ber_dupbv( &scbva[0], &si->si_syncCookie.octet_str[0] );
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
mod->sml_op = LDAP_MOD_REPLACE;
- mod->sml_desc = slap_schema.si_ad_subtreeSpecification;
+ mod->sml_desc = slap_schema.si_ad_syncreplCookie;
mod->sml_type = mod->sml_desc->ad_cname;
- mod->sml_values = ssbva;
+ mod->sml_values = scbva;
*modtail = mod;
modtail = &mod->sml_next;
op->o_tag = LDAP_REQ_ADD;
rc = slap_mods_opattrs( op, modlist, modtail,
- &text,txtbuf, textlen );
+ &text, txtbuf, textlen, 0 );
for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
ml->sml_op = LDAP_MOD_REPLACE;
/* update persistent cookie */
update_cookie_retry:
op->o_tag = LDAP_REQ_MODIFY;
- op->orm_modlist = modlist;
+ /* Just modify the cookie value, not the entire entry */
+ op->orm_modlist = mod;
rc = be->be_modify( op, &rs_modify );
if ( rs_modify.sr_err != LDAP_SUCCESS ) {
"dn_callback : consistency error - entryUUID is not unique\n", 0, 0, 0 );
#endif
} else {
- ber_dupbv_x( &si->si_syncUUID_ndn, &rs->sr_entry->e_nname, op->o_tmpmemctx );
+ ber_dupbv_x( &si->si_syncUUID_ndn, &rs->sr_entry->e_nname, NULL );
}
} else if ( rs->sr_type == REP_RESULT ) {
if ( rs->sr_err == LDAP_SIZELIMIT_EXCEEDED ) {
}
ch_free ( (char *) bv );
}
+
+void
+syncinfo_free( syncinfo_t *sie )
+{
+ if ( sie->si_provideruri ) {
+ ch_free( sie->si_provideruri );
+ }
+ if ( sie->si_provideruri_bv ) {
+ ber_bvarray_free( sie->si_provideruri_bv );
+ }
+ if ( sie->si_updatedn.bv_val ) {
+ ch_free( sie->si_updatedn.bv_val );
+ }
+ if ( sie->si_binddn ) {
+ ch_free( sie->si_binddn );
+ }
+ if ( sie->si_passwd ) {
+ ch_free( sie->si_passwd );
+ }
+ if ( sie->si_saslmech ) {
+ ch_free( sie->si_saslmech );
+ }
+ if ( sie->si_secprops ) {
+ ch_free( sie->si_secprops );
+ }
+ if ( sie->si_realm ) {
+ ch_free( sie->si_realm );
+ }
+ if ( sie->si_authcId ) {
+ ch_free( sie->si_authcId );
+ }
+ if ( sie->si_authzId ) {
+ ch_free( sie->si_authzId );
+ }
+ if ( sie->si_filterstr.bv_val ) {
+ ch_free( sie->si_filterstr.bv_val );
+ }
+ if ( sie->si_base.bv_val ) {
+ ch_free( sie->si_base.bv_val );
+ }
+ if ( sie->si_attrs ) {
+ int i = 0;
+ while ( sie->si_attrs[i] != NULL ) {
+ ch_free( sie->si_attrs[i] );
+ i++;
+ }
+ ch_free( sie->si_attrs );
+ }
+ if ( sie->si_exattrs ) {
+ int i = 0;
+ while ( sie->si_exattrs[i] != NULL ) {
+ ch_free( sie->si_exattrs[i] );
+ i++;
+ }
+ ch_free( sie->si_exattrs );
+ }
+ if ( sie->si_retryinterval ) {
+ ch_free( sie->si_retryinterval );
+ }
+ if ( sie->si_retrynum ) {
+ ch_free( sie->si_retrynum );
+ }
+ if ( sie->si_retrynum_init ) {
+ ch_free( sie->si_retrynum_init );
+ }
+ slap_sync_cookie_free( &sie->si_syncCookie, 0 );
+ if ( sie->si_syncUUID_ndn.bv_val ) {
+ ch_free( sie->si_syncUUID_ndn.bv_val );
+ }
+ if ( sie->si_presentlist ) {
+ avl_free( sie->si_presentlist, avl_ber_bvfree );
+ }
+ if ( sie->si_ld ) {
+ ldap_ld_free( sie->si_ld, 1, NULL, NULL );
+ }
+ while ( !LDAP_LIST_EMPTY( &sie->si_nonpresentlist )) {
+ struct nonpresent_entry* npe;
+ npe = LDAP_LIST_FIRST( &sie->si_nonpresentlist );
+ LDAP_LIST_REMOVE( npe, npe_link );
+ if ( npe->npe_name ) {
+ if ( npe->npe_name->bv_val ) {
+ ch_free( npe->npe_name->bv_val );
+ }
+ ch_free( npe->npe_name );
+ }
+ if ( npe->npe_nname ) {
+ if ( npe->npe_nname->bv_val ) {
+ ch_free( npe->npe_nname->bv_val );
+ }
+ ch_free( npe->npe_nname );
+ }
+ ch_free( npe );
+ }
+ ch_free( sie );
+}