]> git.sur5r.net Git - openldap/commitdiff
Add first cut BDB no-op control support.
authorKurt Zeilenga <kurt@openldap.org>
Tue, 29 Jan 2002 00:02:27 +0000 (00:02 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 29 Jan 2002 00:02:27 +0000 (00:02 +0000)
servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/id2entry.c
servers/slapd/back-bdb/init.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-bdb/passwd.c

index 6d03e22db0f85e6cfd000bd62aeb9fc8ff231adc..961aa0a8ed7479102ff91108cf64feb545e81942 100644 (file)
@@ -339,33 +339,41 @@ retry:    /* transaction retry */
                goto return_results;
        }
 
-       rc = txn_commit( ltid, 0 );
+       if( op->o_noop ) {
+               rc = txn_abort( ltid );
+       } else {
+               rc = txn_commit( ltid, 0 );
+       }
        ltid = NULL;
        op->o_private = NULL;
 
        if( rc != 0 ) {
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_add: txn_commit failed: %s (%d)\n",
-                       db_strerror(rc), rc, 0 );
+                       "bdb_add: txn_%s failed: %s (%d)\n",
+                       op->o_noop ? "abort (no-op)" : "commit",
+                       db_strerror(rc), rc );
                rc = LDAP_OTHER;
                text = "commit failed";
 
        } else {
-                /* add the entry to the entry cache */
-                /* we should add to cache only upon free of txn-abort */
-                if (bdb_cache_add_entry_rw(&bdb->bi_cache, e, CACHE_WRITE_LOCK) != 0) {
-                        text = "cache add failed";
-                        goto return_results;
-                }
+               /* add the entry to the entry cache */
+               /* we should add to cache only upon free of txn-abort */
+               if (!op->o_noop &&
+                       bdb_cache_add_entry_rw(&bdb->bi_cache, e, CACHE_WRITE_LOCK) != 0)
+               {
+                       text = "cache add failed";
+                       goto return_results;
+               }
  
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_add: added id=%08lx dn=\"%s\"\n",
-                       e->e_id, e->e_dn, 0 );
+                       "bdb_add: added%s id=%08lx dn=\"%s\"\n",
+                       op->o_noop ? " (no-op)" : "",
+                       e->e_id, e->e_dn );
                rc = LDAP_SUCCESS;
                text = NULL;
        }
 
-       bdb_cache_entry_commit (e);
+       bdb_cache_entry_commit( e );
 
 return_results:
        send_ldap_result( conn, op, rc,
index b79cf104df12cc06dd415859fae876fa3f539299..f09b2963b1623e20724f264275d16388e3fd3758 100644 (file)
@@ -332,21 +332,27 @@ retry:    /* transaction retry */
        ldap_pvt_thread_mutex_unlock( &bdb->bi_lastid_mutex );
 #endif
 
-       rc = txn_commit( ltid, 0 );
+       if( op->o_noop ) {
+               rc = txn_abort( ltid );
+       } else {
+               rc = txn_commit( ltid, 0 );
+       }
        ltid = NULL;
        op->o_private = NULL;
 
        if( rc != 0 ) {
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_delete: txn_commit failed: %s (%d)\n",
-                       db_strerror(rc), rc, 0 );
+                       "bdb_delete: txn_%s failed: %s (%d)\n",
+                       op->o_noop ? "abort (no-op)" : "commit",
+                       db_strerror(rc), rc );
                rc = LDAP_OTHER;
                text = "commit failed";
 
        } else {
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_delete: deleted id=%08lx dn=\"%s\"\n",
-                       e->e_id, e->e_dn, 0 );
+                       "bdb_delete: deleted%s id=%08lx dn=\"%s\"\n",
+                       op->o_noop ? " (no-op)" : "",
+                       e->e_id, e->e_dn );
                rc = LDAP_SUCCESS;
                text = NULL;
        }
index c67359c339e8152be83ee6d341e430bb9df4ab41..037183b547afcbddcfae18fba86bcc8c0f049db8 100644 (file)
@@ -135,8 +135,9 @@ int bdb_id2entry_rw(
        bdb_fix_dn(be, id, *e);
 #endif
 
-       if (rc == 0)
+       if (rc == 0) {
                bdb_cache_entry_commit(*e);
+       }
 
        return rc;
 }
index c61a1618d93f7b03ba1bd60f5e46f9642ec8ab93..b51ca852b96c42046b71ae6bacff2d02d8941b9b 100644 (file)
@@ -401,9 +401,7 @@ bdb_initialize(
        static char *controls[] = {
                LDAP_CONTROL_MANAGEDSAIT,
                LDAP_CONTROL_SUBENTRIES,
-#if 0
                LDAP_CONTROL_NOOP,
-#endif
                NULL
        };
 
index 44002bf3257574669873477a1b7e93214ac5b8c0..f21eba17d9d995421b5f61277f49529b0e945409 100644 (file)
@@ -328,20 +328,26 @@ retry:    /* transaction retry */
                goto return_results;
        }
 
-       rc = txn_commit( ltid, 0 );
+       if( op->o_noop ) {
+               rc = txn_abort( ltid );
+       } else {
+               rc = txn_commit( ltid, 0 );
+       }
        ltid = NULL;
        op->o_private = NULL;
 
        if( rc != 0 ) {
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_modify: txn_commit failed: %s (%d)\n",
-                       db_strerror(rc), rc, 0 );
+                       "bdb_modify: txn_%s failed: %s (%d)\n",
+                       op->o_noop ? "abort (no-op)" : "commit",
+                       db_strerror(rc), rc );
                rc = LDAP_OTHER;
                text = "commit failed";
 
        } else {
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_modify: updated id=%08lx dn=\"%s\"\n",
+                       "bdb_modify: updated%s id=%08lx dn=\"%s\"\n",
+                       op->o_noop ? " (no-op)" : "",
                        e->e_id, e->e_dn, 0 );
                rc = LDAP_SUCCESS;
                text = NULL;
index 5e9e4776a486b414166a9d587131c4daae1e60d6..73c7d212520cc21f5fdc27a49247530a66fc723b 100644 (file)
@@ -620,21 +620,28 @@ retry:    /* transaction retry */
                goto return_results;
        }
 
-       rc = txn_commit( ltid, 0 );
+       if( op->o_noop ) {
+               rc = txn_abort( ltid );
+       } else {
+               rc = txn_commit( ltid, 0 );
+       }
        ltid = NULL;
        op->o_private = NULL;
 
        if( rc != 0 ) {
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_modrdn: txn_commit failed: %s (%d)\n",
-                       db_strerror(rc), rc, 0 );
+                       "bdb_modrdn: txn_%s failed: %s (%d)\n",
+                       op->o_noop ? "abort (no-op)" : "commit",
+                       db_strerror(rc), rc );
                rc = LDAP_OTHER;
                text = "commit failed";
+
        } else {
                (void) bdb_cache_update_entry(&bdb->bi_cache, e);
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_modrdn: added id=%08lx dn=\"%s\"\n",
-                       e->e_id, e->e_dn, 0 );
+                       "bdb_modrdn: added%s id=%08lx dn=\"%s\"\n",
+                       op->o_noop ? " (no-op)" : "",
+                       e->e_id, e->e_dn );
                rc = LDAP_SUCCESS;
                text = NULL;
                bdb_cache_entry_commit( e );
index cbad790f1c3833bbf3ac7b33f5a9526c68bc577e..003f85691adcd749074bc8e1d3c9bcd8f10fa8fa 100644 (file)
@@ -198,7 +198,11 @@ retry:     /* transaction retry */
                }
 
                if( rc == 0 ) {
-                       rc = txn_commit( ltid, 0 );
+                       if( op->o_noop ) {
+                               rc = txn_abort( ltid );
+                       } else {
+                               rc = txn_commit( ltid, 0 );
+                       }
                        ltid = NULL;
                }
                op->o_private = NULL;