From: Howard Chu Date: Wed, 24 Dec 2003 13:27:03 +0000 (+0000) Subject: ITS#2895 TXN_PREPARE is not needed since we use nested transactions. It X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~106 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e6f34fddcdd5dc0b9a1e272de7ed833c5d787ac8;p=openldap ITS#2895 TXN_PREPARE is not needed since we use nested transactions. It also has a side-effect of releasing all the transaction's existing locks. --- diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index c807f24416..e08f764c4c 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -465,52 +465,41 @@ retry: /* transaction retry */ } } 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"; + struct berval nrdn; + Entry *e = entry_dup( op->ora_e ); + if (pdn.bv_len) { + nrdn.bv_val = e->e_nname.bv_val; + nrdn.bv_len = pdn.bv_val - op->ora_e->e_nname.bv_val - 1; } else { - struct berval nrdn; - Entry *e = entry_dup( op->ora_e ); - - if (pdn.bv_len) { - nrdn.bv_val = e->e_nname.bv_val; - nrdn.bv_len = pdn.bv_val - op->ora_e->e_nname.bv_val - 1; - } else { - nrdn = e->e_nname; - } + nrdn = e->e_nname; + } - bdb_cache_add( bdb, ei, e, &nrdn, locker ); + bdb_cache_add( bdb, ei, e, &nrdn, locker ); - if ( suffix_ei == NULL ) { - suffix_ei = e->e_private; - } + if ( suffix_ei == NULL ) { + suffix_ei = e->e_private; + } - if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { - if ( ctxcsn_added ) { - bdb_cache_add( bdb, suffix_ei, ctxcsn_e, - (struct berval *)&slap_ldapsync_cn_bv, locker ); - } + if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { + if ( ctxcsn_added ) { + bdb_cache_add( bdb, suffix_ei, ctxcsn_e, + (struct berval *)&slap_ldapsync_cn_bv, locker ); } + } - if ( rs->sr_err == LDAP_SUCCESS && !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, op->oq_add.rs_e, LDAP_PSEARCH_BY_ADD ); - } - ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock ); + if ( rs->sr_err == LDAP_SUCCESS && !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, op->oq_add.rs_e, LDAP_PSEARCH_BY_ADD ); } + ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock ); + } - if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) { - rs->sr_text = "txn_commit failed"; - } else { - rs->sr_err = LDAP_SUCCESS; - } + if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) { + rs->sr_text = "txn_commit failed"; + } else { + rs->sr_err = LDAP_SUCCESS; } } diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index 087f9571a8..9debb6c59c 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -617,8 +617,6 @@ retry: /* transaction retry */ rs->sr_err = LDAP_SUCCESS; } } else { - EntryInfo *ctx_ei; - bdb_cache_modify( e, dummy.e_attrs, bdb->bi_dbenv, locker, &lock ); if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 50f0ad6143..f1d58647f8 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -980,49 +980,39 @@ retry: /* transaction retry */ } } else { - char gid[DB_XIDDATASIZE]; + bdb_cache_modrdn( save, &op->orr_nnewrdn, e, neip, + bdb->bi_dbenv, locker, &lock ); - 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 { - bdb_cache_modrdn( save, &op->orr_nnewrdn, e, neip, - bdb->bi_dbenv, locker, &lock ); - - if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { - if ( ctxcsn_added ) { - bdb_cache_add( bdb, suffix_ei, ctxcsn_e, - (struct berval *)&slap_ldapsync_cn_bv, locker ); - } + if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) { + if ( ctxcsn_added ) { + 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 ); - } + 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 ); } - - if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) { - rs->sr_text = "txn_commit failed"; - } else { - rs->sr_err = LDAP_SUCCESS; + 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 ); } } + + if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) { + rs->sr_text = "txn_commit failed"; + } else { + rs->sr_err = LDAP_SUCCESS; + } } ltid = NULL;