]> git.sur5r.net Git - openldap/commitdiff
ITS#2895 TXN_PREPARE is not needed since we use nested transactions. It
authorHoward Chu <hyc@openldap.org>
Wed, 24 Dec 2003 13:27:03 +0000 (13:27 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 24 Dec 2003 13:27:03 +0000 (13:27 +0000)
also has a side-effect of releasing all the transaction's existing locks.

servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c

index c807f24416ebfe26ebbdcc78acbba10e2b60367f..e08f764c4cca4c36835bde5f738aefac94624bf7 100644 (file)
@@ -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;
                }
        }
 
index 087f9571a89b775b1f6cdc367ede65244b81a92e..9debb6c59cda4619e9c8134fff62df805dbf5bc9 100644 (file)
@@ -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 )) {
index 50f0ad614326e48e2a7bf1598a14f487fc8030ac..f1d58647f8faa3e1a5ee9c471de67e117f2a1818 100644 (file)
@@ -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;