psub = &si->si_be->be_nsuffix[0];
/* Init connection to master */
- rc = ldap_initialize( &si->si_ld, si->si_provideruri );
+ rc = ldap_initialize( &si->si_ld, si->si_provideruri.bv_val );
if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY,
"do_syncrep1: ldap_initialize failed (%s)\n",
- si->si_provideruri, 0, 0 );
+ si->si_provideruri.bv_val, 0, 0 );
return rc;
}
if( rc != LDAP_OPT_SUCCESS ) {
Debug( LDAP_DEBUG_ANY, "Error: ldap_set_option "
"(%s,SECPROPS,\"%s\") failed!\n",
- si->si_provideruri, si->si_secprops, 0 );
+ si->si_provideruri.bv_val, si->si_secprops, 0 );
goto done;
}
}
msg != NULL;
msg = ldap_next_message( si->si_ld, msg ) )
{
+ if ( slapd_shutdown ) {
+ rc = -2;
+ goto done;
+ }
switch( ldap_msgtype( msg ) ) {
case LDAP_RES_SEARCH_ENTRY:
ldap_get_entry_controls( si->si_ld, msg, &rctrls );
if ( si == NULL )
return NULL;
+ ldap_pvt_thread_mutex_lock( &si->si_mutex );
+
switch( abs( si->si_type )) {
case LDAP_SYNC_REFRESH_ONLY:
case LDAP_SYNC_REFRESH_AND_PERSIST:
break;
default:
+ ldap_pvt_thread_mutex_unlock( &si->si_mutex );
return NULL;
}
ldap_unbind( si->si_ld );
si->si_ld = NULL;
}
+ ldap_pvt_thread_mutex_unlock( &si->si_mutex );
return NULL;
}
}
ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
+ ldap_pvt_thread_mutex_unlock( &si->si_mutex );
return NULL;
}
SlapReply rs_add = {REP_RESULT};
SlapReply rs_modify = {REP_RESULT};
Filter f = {0};
- AttributeAssertion ava = {0};
+ AttributeAssertion ava = { NULL, BER_BVNULL, NULL };
int rc = LDAP_SUCCESS;
int ret = LDAP_SUCCESS;
struct berval pdn = BER_BVNULL;
- struct berval org_req_dn = BER_BVNULL;
- struct berval org_req_ndn = BER_BVNULL;
- int org_managedsait;
dninfo dni = {0};
int retry = 1;
ava.aa_value = *syncUUID;
op->ors_filter = &f;
- op->ors_filterstr.bv_len = STRLENOF( "entryUUID=" ) + syncUUID->bv_len;
+ op->ors_filterstr.bv_len = STRLENOF( "(entryUUID=)" ) + syncUUID->bv_len;
op->ors_filterstr.bv_val = (char *) slap_sl_malloc(
op->ors_filterstr.bv_len + 1, op->o_tmpmemctx );
- AC_MEMCPY( op->ors_filterstr.bv_val, "entryUUID=", STRLENOF( "entryUUID=" ) );
- AC_MEMCPY( &op->ors_filterstr.bv_val[STRLENOF( "entryUUID=" )],
+ AC_MEMCPY( op->ors_filterstr.bv_val, "(entryUUID=", STRLENOF( "(entryUUID=" ) );
+ AC_MEMCPY( &op->ors_filterstr.bv_val[STRLENOF( "(entryUUID=" )],
syncUUID->bv_val, syncUUID->bv_len );
+ op->ors_filterstr.bv_val[op->ors_filterstr.bv_len - 1] = ')';
op->ors_filterstr.bv_val[op->ors_filterstr.bv_len] = '\0';
op->o_tag = LDAP_REQ_SEARCH;
cb.sc_response = null_callback;
cb.sc_private = si;
- if ( entry && entry->e_name.bv_val ) {
+ if ( entry && !BER_BVISNULL( &entry->e_name ) ) {
Debug( LDAP_DEBUG_SYNC,
"syncrepl_entry: %s\n",
entry->e_name.bv_val, 0, 0 );
dni.dn.bv_val ? dni.dn.bv_val : "(null)", 0, 0 );
}
- org_req_dn = op->o_req_dn;
- org_req_ndn = op->o_req_ndn;
- org_managedsait = get_manageDSAit( op );
- op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
-
if ( syncstate != LDAP_SYNC_DELETE ) {
- attr_delete( &entry->e_attrs, slap_schema.si_ad_entryUUID );
- attr_merge_one( entry, slap_schema.si_ad_entryUUID,
- &syncUUID_strrep, syncUUID );
+ Attribute *a = attr_find( entry->e_attrs, slap_schema.si_ad_entryUUID );
+
+ if ( a == NULL ) {
+ /* add if missing */
+ attr_merge_one( entry, slap_schema.si_ad_entryUUID,
+ &syncUUID_strrep, syncUUID );
+
+ } else if ( !bvmatch( &a->a_nvals[0], syncUUID ) ) {
+ /* replace only if necessary */
+ if ( a->a_nvals != a->a_vals ) {
+ ber_memfree( a->a_nvals[0].bv_val );
+ ber_dupbv( &a->a_nvals[0], syncUUID );
+ }
+ ber_memfree( a->a_vals[0].bv_val );
+ ber_dupbv( &a->a_vals[0], &syncUUID_strrep );
+ }
}
switch ( syncstate ) {
struct berval pdn = BER_BVNULL;
struct berval org_req_dn = BER_BVNULL;
struct berval org_req_ndn = BER_BVNULL;
- int org_managedsait;
op->o_req_dn = si->si_base;
op->o_req_ndn = si->si_base;
if ( uuids ) {
Filter uf;
- AttributeAssertion eq;
+ AttributeAssertion eq = { NULL, BER_BVNULL, NULL };
int i;
op->ors_attrsonly = 1;
op->ors_attrs = slap_anlist_no_attrs;
op->ors_limit = NULL;
op->ors_filter = &uf;
- op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
uf.f_ava = &eq;
uf.f_av_desc = slap_schema.si_ad_entryUUID;
op->ors_filter = str2filter_x( op, si->si_filterstr.bv_val );
op->ors_filterstr = si->si_filterstr;
op->o_nocaching = 1;
- op->o_managedsait = SLAP_CONTROL_NONE;
if ( limits_check( op, &rs_search ) == 0 ) {
rc = be->be_search( op, &rs_search );
if ( op->ors_filter ) filter_free_x( op, op->ors_filter );
}
- op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
op->o_nocaching = 0;
if ( !LDAP_LIST_EMPTY( &si->si_nonpresentlist ) ) {
rc = be->be_modify( op, &rs_modify );
}
- org_managedsait = get_manageDSAit( op );
- op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
-
while ( rs_delete.sr_err == LDAP_SUCCESS &&
op->o_delete_glue_parent ) {
op->o_delete_glue_parent = 0;
}
}
- op->o_managedsait = org_managedsait;
- op->o_req_dn = org_req_dn;
- op->o_req_ndn = org_req_ndn;
op->o_delete_glue_parent = 0;
ber_bvfree( np_prev->npe_name );
ber_bvfree( np_prev->npe_nname );
- BER_BVZERO( &op->o_req_dn );
- BER_BVZERO( &op->o_req_ndn );
ch_free( np_prev );
}
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 );
+ ldap_pvt_thread_mutex_destroy( &sie->si_mutex );
+ if ( !BER_BVISNULL( &sie->si_provideruri ) ) {
+ ch_free( sie->si_provideruri.bv_val );
}
if ( sie->si_binddn ) {
ch_free( sie->si_binddn );