/* modrdn.c - bdb backend modrdn routine */
/* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 2000-2003 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
*/
#include "portable.h"
#else
Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn: retrying...\n", 0, 0, 0 );
#endif
-
pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
while ( pm_list != NULL ) {
LDAP_LIST_REMOVE ( pm_list, ps_link );
rs->sr_text = "internal error";
goto return_results;
}
- bdb_trans_backoff( ++num_retries );
ldap_pvt_thread_yield();
+ bdb_trans_backoff( ++num_retries );
}
/* begin transaction */
e = NULL;
} else {
- BerVarray deref = op->o_bd->syncinfo ?
- op->o_bd->syncinfo->provideruri_bv : default_referral;
- rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
+ BerVarray deref = NULL;
+ if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
+ syncinfo_t *si;
+ LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
+ struct berval tmpbv;
+ ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] );
+ ber_bvarray_add( &deref, &tmpbv );
+ }
+ } else {
+ deref = default_referral;
+ }
+ rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
+ LDAP_SCOPE_DEFAULT );
}
rs->sr_err = LDAP_REFERRAL;
}
/* Build target dn and make sure target entry doesn't exist already. */
- if (!new_dn.bv_val) build_new_dn( &new_dn, new_parent_dn, &op->oq_modrdn.rs_newrdn );
+ if (!new_dn.bv_val) build_new_dn( &new_dn, new_parent_dn, &op->oq_modrdn.rs_newrdn, NULL );
if (!new_ndn.bv_val) {
struct berval bv = {0, NULL};
/* Shortcut the search */
nei = neip ? neip : eip;
- rs->sr_err = bdb_cache_find_ndn ( op, ltid, &new_ndn, &nei, locker );
+ rs->sr_err = bdb_cache_find_ndn ( op, ltid, &new_ndn, &nei );
if ( nei ) bdb_cache_entryinfo_unlock( nei );
switch( rs->sr_err ) {
case DB_LOCK_DEADLOCK:
goto return_results;
}
- if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
+ if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop && !op->o_no_psearch ) {
+ ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock );
LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_PREMODIFY );
}
+ ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock );
}
/* modify entry */
goto return_results;
}
- if ( !op->o_bd->syncinfo ) {
- rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei, &ctxcsn_e, &ctxcsn_added, locker );
+ if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
+ rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei,
+ &ctxcsn_e, &ctxcsn_added, locker );
switch ( rc ) {
case BDB_CSN_ABORT :
goto return_results;
} else {
char gid[DB_XIDDATASIZE];
+ memset( gid, 0, sizeof(gid) );
snprintf( gid, sizeof( gid ), "%s-%08lx-%08lx",
bdb_uuid.bv_val, (long) op->o_connid, (long) op->o_opid );
if(( rs->sr_err=TXN_PREPARE( ltid, gid )) != 0 ) {
rs->sr_text = "txn_prepare failed";
} else {
- struct berval ctx_nrdn;
-
bdb_cache_modrdn( save, &op->orr_nnewrdn, e, neip,
bdb->bi_dbenv, locker, &lock );
- if ( !op->o_bd->syncinfo ) {
+ if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
if ( ctxcsn_added ) {
- ctx_nrdn.bv_val = "cn=ldapsync";
- ctx_nrdn.bv_len = strlen( ctx_nrdn.bv_val );
- bdb_cache_add( bdb, suffix_ei, ctxcsn_e, &ctx_nrdn, locker );
+ bdb_cache_add( bdb, suffix_ei, ctxcsn_e,
+ (struct berval *)&slap_ldapsync_cn_bv, locker );
+ }
+ }
+
+ if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
+ /* Loop through in-scope entries for each psearch spec */
+ ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock );
+ LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
+ bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_MODIFY );
+ }
+ ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock );
+ pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
+ while ( pm_list != NULL ) {
+ bdb_psearch(op, rs, pm_list->ps_op,
+ e, LDAP_PSEARCH_BY_SCOPEOUT);
+ pm_prev = pm_list;
+ LDAP_LIST_REMOVE ( pm_list, ps_link );
+ pm_list = LDAP_LIST_NEXT ( pm_list, ps_link );
+ ch_free( pm_prev );
}
}
return_results:
send_ldap_result( op, rs );
- if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
- /* Loop through in-scope entries for each psearch spec */
- LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
- bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_MODIFY );
- }
- pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
- while ( pm_list != NULL ) {
- bdb_psearch(op, rs, pm_list->ps_op,
- e, LDAP_PSEARCH_BY_SCOPEOUT);
- pm_prev = pm_list;
- LDAP_LIST_REMOVE ( pm_list, ps_link );
- pm_list = LDAP_LIST_NEXT ( pm_list, ps_link );
- ch_free( pm_prev );
- }
- }
-
if( rs->sr_err == LDAP_SUCCESS && bdb->bi_txn_cp ) {
ldap_pvt_thread_yield();
TXN_CHECKPOINT( bdb->bi_dbenv,
Modifications *tmp;
for (; mod; mod=tmp ) {
tmp = mod->sml_next;
+ /* slap_modrdn2mods does things one way,
+ * slap_mods_opattrs does it differently
+ */
+ if ( mod->sml_op != SLAP_MOD_SOFTADD &&
+ mod->sml_op != LDAP_MOD_DELETE ) break;
if ( mod->sml_nvalues ) free( mod->sml_nvalues[0].bv_val );
free( mod );
}
+ slap_mods_free( mod );
}
/* LDAP v3 Support */