The branch, master has been updated
       via  319a97bce9f77161e62de9f86ddbec58629238cb (commit)
       via  d5efb38151dea179af920a1a279d974a47b6bfd6 (commit)
      from  760104188d0d2ed96ec4a70138e6d0bf86d797ed (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 319a97bce9f77161e62de9f86ddbec58629238cb
Author: Michael Adam <ob...@samba.org>
Date:   Tue Jul 21 12:35:48 2009 +0200

    s3:dbwrap: use the transaction wrapper in dbwrap_trans_store().
    
    Now dbwrap_util.c contains only one call to each of
    transaction_start, transaction_commit and transaction_cancel.
    
    Michael

commit d5efb38151dea179af920a1a279d974a47b6bfd6
Author: Michael Adam <ob...@samba.org>
Date:   Tue Jul 21 12:26:14 2009 +0200

    s3:dbwrap: use the transaction wrapper in dbwrap_trans_delete().
    
    Michael

-----------------------------------------------------------------------

Summary of changes:
 source3/lib/dbwrap_util.c |   89 ++++++++++++++++++---------------------------
 1 files changed, 35 insertions(+), 54 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/dbwrap_util.c b/source3/lib/dbwrap_util.c
index 7dbeb63..c3ab93c 100644
--- a/source3/lib/dbwrap_util.c
+++ b/source3/lib/dbwrap_util.c
@@ -179,96 +179,77 @@ int32 dbwrap_change_int32_atomic(struct db_context *db, 
const char *keystr,
        return 0;
 }
 
-NTSTATUS dbwrap_trans_store(struct db_context *db, TDB_DATA key, TDB_DATA dbuf,
-                           int flag)
+struct dbwrap_store_context {
+       TDB_DATA *key;
+       TDB_DATA *dbuf;
+       int flag;
+};
+
+static NTSTATUS dbwrap_store_action(struct db_context *db, void *private_data)
 {
-       int res;
        struct db_record *rec = NULL;
        NTSTATUS status;
+       struct dbwrap_store_context *store_ctx;
 
-       res = db->transaction_start(db);
-       if (res != 0) {
-               DEBUG(5, ("transaction_start failed\n"));
-               return NT_STATUS_INTERNAL_DB_CORRUPTION;
-       }
+       store_ctx = (struct dbwrap_store_context *)private_data;
 
-       rec = db->fetch_locked(db, talloc_tos(), key);
+       rec = db->fetch_locked(db, talloc_tos(), *(store_ctx->key));
        if (rec == NULL) {
                DEBUG(5, ("fetch_locked failed\n"));
-               status = NT_STATUS_NO_MEMORY;
-               goto cancel;
+               return NT_STATUS_NO_MEMORY;
        }
 
-       status = rec->store(rec, dbuf, flag);
+       status = rec->store(rec, *(store_ctx->dbuf), store_ctx->flag);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(5, ("store returned %s\n", nt_errstr(status)));
-               goto cancel;
        }
 
        TALLOC_FREE(rec);
+       return status;
+}
 
-       res = db->transaction_commit(db);
-       if (res != 0) {
-               DEBUG(5, ("tdb_transaction_commit failed\n"));
-               status = NT_STATUS_INTERNAL_DB_CORRUPTION;
-               TALLOC_FREE(rec);
-               return status;
-       }
+NTSTATUS dbwrap_trans_store(struct db_context *db, TDB_DATA key, TDB_DATA dbuf,
+                           int flag)
+{
+       NTSTATUS status;
+       struct dbwrap_store_context store_ctx;
 
-       return NT_STATUS_OK;
+       store_ctx.key = &key;
+       store_ctx.dbuf = &dbuf;
+       store_ctx.flag = flag;
 
- cancel:
-       TALLOC_FREE(rec);
+       status = dbwrap_trans_do(db, dbwrap_store_action, &store_ctx);
 
-       if (db->transaction_cancel(db) != 0) {
-               smb_panic("Cancelling transaction failed");
-       }
        return status;
 }
 
-NTSTATUS dbwrap_trans_delete(struct db_context *db, TDB_DATA key)
+static NTSTATUS dbwrap_delete_action(struct db_context * db, void 
*private_data)
 {
-       int res;
-       struct db_record *rec = NULL;
        NTSTATUS status;
+       struct db_record *rec;
+       TDB_DATA *key = (TDB_DATA *)private_data;
 
-       res = db->transaction_start(db);
-       if (res != 0) {
-               DEBUG(5, ("transaction_start failed\n"));
-               return NT_STATUS_INTERNAL_DB_CORRUPTION;
-       }
-
-       rec = db->fetch_locked(db, talloc_tos(), key);
+       rec = db->fetch_locked(db, talloc_tos(), *key);
        if (rec == NULL) {
                DEBUG(5, ("fetch_locked failed\n"));
-               status = NT_STATUS_NO_MEMORY;
-               goto cancel;
+               return NT_STATUS_NO_MEMORY;
        }
 
        status = rec->delete_rec(rec);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(5, ("delete_rec returned %s\n", nt_errstr(status)));
-               goto cancel;
        }
 
-       TALLOC_FREE(rec);
-
-       res = db->transaction_commit(db);
-       if (res != 0) {
-               DEBUG(5, ("tdb_transaction_commit failed\n"));
-               status = NT_STATUS_INTERNAL_DB_CORRUPTION;
-               TALLOC_FREE(rec);
-               return status;          
-       }
+       talloc_free(rec);
+       return  status;
+}
 
-       return NT_STATUS_OK;
+NTSTATUS dbwrap_trans_delete(struct db_context *db, TDB_DATA key)
+{
+       NTSTATUS status;
 
- cancel:
-       TALLOC_FREE(rec);
+       status = dbwrap_trans_do(db, dbwrap_delete_action, &key);
 
-       if (db->transaction_cancel(db) != 0) {
-               smb_panic("Cancelling transaction failed");
-       }
        return status;
 }
 


-- 
Samba Shared Repository

Reply via email to