]> git.sur5r.net Git - openldap/commitdiff
improved support for NOOP; add is fine, the other write funcs still need work
authorPierangelo Masarati <ando@openldap.org>
Sat, 31 Aug 2002 12:00:39 +0000 (12:00 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 31 Aug 2002 12:00:39 +0000 (12:00 +0000)
servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c

index 983ddd9dba9c5c56ab6d25c083c8f70a85c7885c..d00d88d0c5261440e5a1b8df9f6e5c2d15ca1b52 100644 (file)
@@ -23,7 +23,7 @@ bdb_add(
        struct bdb_info *bdb = (struct bdb_info *) be->be_private;
        struct berval   pdn;
        Entry           *p = NULL;
-       int             rc, ret
+       int             rc; 
        const char      *text;
        char textbuf[SLAP_TEXT_BUFLEN];
        size_t textlen = sizeof textbuf;
@@ -39,6 +39,7 @@ bdb_add(
        u_int32_t       lockid;
        DB_LOCK         lock;
 #endif
+       int             noop = 0;
 
 #ifdef NEW_LOGGING
        LDAP_LOG ( OPERATION, ARGS, "==> bdb_add: %s\n", e->e_dn, 0, 0 );
@@ -434,6 +435,7 @@ retry:      /* transaction retry */
                if (( rc=TXN_ABORT( ltid )) != 0 ) {
                        text = "txn_abort (no-op) failed";
                } else {
+                       noop = 1;
                        rc = LDAP_SUCCESS;
                }
 
@@ -447,7 +449,9 @@ retry:      /* transaction retry */
                        text = "txn_prepare failed";
 
                } else {
-                       ret = bdb_cache_add_entry_rw(bdb->bi_dbenv, &bdb->bi_cache, e, CACHE_WRITE_LOCK, locker, &lock);
+                       int ret = bdb_cache_add_entry_rw(bdb->bi_dbenv,
+                                       &bdb->bi_cache, e, CACHE_WRITE_LOCK,
+                                       locker, &lock);
 #if 0
                        if ( bdb_cache_add_entry_rw(&bdb->bi_cache,
                                e, CACHE_WRITE_LOCK) != 0 )
@@ -492,7 +496,9 @@ retry:      /* transaction retry */
                        op->o_noop ? " (no-op)" : "", e->e_id, e->e_dn );
 #endif
                text = NULL;
-               bdb_cache_entry_commit( e );
+               if ( !noop ) {
+                       bdb_cache_entry_commit( e );
+               }
        }
        else {
 #ifdef NEW_LOGGING
@@ -522,5 +528,5 @@ done:
                op->o_private = NULL;
        }
 
-       return rc;
+       return ( ( rc == LDAP_SUCCESS ) ? noop : rc );
 }
index c15662b15d8b494a1c48e5c8b4a00618f71e51c4..6052c6ea91ef40a0b8eeda3f8bee6d8075fa683b 100644 (file)
@@ -41,6 +41,8 @@ bdb_delete(
        DB_LOCK         lock;
 #endif
 
+       int             noop = 0;
+
 #ifdef NEW_LOGGING
        LDAP_LOG ( OPERATION, ARGS,  "==> bdb_delete: %s\n", dn->bv_val, 0, 0 );
 #else
@@ -416,7 +418,12 @@ retry:     /* transaction retry */
 #endif
 
        if( op->o_noop ) {
-               rc = TXN_ABORT( ltid );
+               if ( ( rc = TXN_ABORT( ltid ) ) != 0 ) {
+                       text = "txn_abort (no-op) failed";
+               } else {
+                       noop = 1;
+                       rc = LDAP_SUCCESS;
+               }
        } else {
                rc = TXN_COMMIT( ltid, 0 );
        }
@@ -472,5 +479,5 @@ done:
                op->o_private = NULL;
        }
 
-       return rc;
+       return ( ( rc == LDAP_SUCCESS ) ? noop : rc );
 }
index 4f052e404ce7ad154f40c28389826ffcb1552116..bc50253073c24f89dcbab5b214b438b081886910 100644 (file)
@@ -268,6 +268,8 @@ bdb_modify(
        u_int32_t       locker;
        DB_LOCK         lock;
 
+       int             noop = 0;
+
 #ifdef NEW_LOGGING
        LDAP_LOG ( OPERATION, ENTRY, "bdb_modify: %s\n", dn->bv_val, 0, 0 );
 #else
@@ -439,7 +441,12 @@ retry:     /* transaction retry */
        }
 
        if( op->o_noop ) {
-               rc = TXN_ABORT( ltid );
+               if ( ( rc = TXN_ABORT( ltid ) ) != 0 ) {
+                       text = "txn_abort (no-op) failed";
+               } else {
+                       noop = 1;
+                       rc = LDAP_SUCCESS;
+               }
        } else {
                rc = TXN_COMMIT( ltid, 0 );
        }
@@ -494,5 +501,5 @@ done:
        if( e != NULL ) {
                bdb_unlocked_cache_return_entry_w (&bdb->bi_cache, e);
        }
-       return rc;
+       return ( ( rc == LDAP_SUCCESS ) ? noop : rc );
 }
index fe7c2544ce560f5eef0bdc0f69f01a9dea766449..56bc41d28eda682bc2a99e81e342834c412aa7d6 100644 (file)
@@ -59,6 +59,8 @@ bdb_modrdn(
        u_int32_t       locker;
        DB_LOCK         lock;
 
+       int             noop = 0;
+
 #ifdef NEW_LOGGING
        LDAP_LOG ( OPERATION, ENTRY, "==>bdb_modrdn(%s,%s,%s)\n", 
                dn->bv_val,newrdn->bv_val, newSuperior ? newSuperior->bv_val : "NULL" );
@@ -705,6 +707,7 @@ retry:      /* transaction retry */
                if(( rc=TXN_ABORT( ltid )) != 0 ) {
                        text = "txn_abort (no-op) failed";
                } else {
+                       noop = 1;
                        rc = LDAP_SUCCESS;
                }
 
@@ -812,5 +815,5 @@ done:
                op->o_private = NULL;
        }
 
-       return rc;
+       return ( ( rc == LDAP_SUCCESS ) ? noop : rc );
 }