diff options
author | Michael Adam <obnox@samba.org> | 2009-07-21 12:26:14 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2009-07-21 12:40:34 +0200 |
commit | d5efb38151dea179af920a1a279d974a47b6bfd6 (patch) | |
tree | 3f19d5c4ed8ab97ddb9c4f39c5813757e1fa693c | |
parent | 760104188d0d2ed96ec4a70138e6d0bf86d797ed (diff) | |
download | samba-d5efb38151dea179af920a1a279d974a47b6bfd6.tar.gz samba-d5efb38151dea179af920a1a279d974a47b6bfd6.tar.xz samba-d5efb38151dea179af920a1a279d974a47b6bfd6.zip |
s3:dbwrap: use the transaction wrapper in dbwrap_trans_delete().
Michael
-rw-r--r-- | source3/lib/dbwrap_util.c | 40 |
1 files changed, 12 insertions, 28 deletions
diff --git a/source3/lib/dbwrap_util.c b/source3/lib/dbwrap_util.c index 7dbeb639271..32a1dd48e6f 100644 --- a/source3/lib/dbwrap_util.c +++ b/source3/lib/dbwrap_util.c @@ -226,49 +226,33 @@ NTSTATUS dbwrap_trans_store(struct db_context *db, TDB_DATA key, TDB_DATA dbuf, 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; } |