From 2a10d7686553a2c2377165b7f80269d2dcae8847 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 21 Oct 2006 17:00:47 +0000 Subject: r19448: Convert delete_share_security to struct share_params plus some cleanups (This used to be commit c73d0815a3a1f58b951caa62fac601a8f4630894) --- source3/lib/util_tdb.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'source3/lib/util_tdb.c') diff --git a/source3/lib/util_tdb.c b/source3/lib/util_tdb.c index 3e18c09fbf..e847c79369 100644 --- a/source3/lib/util_tdb.c +++ b/source3/lib/util_tdb.c @@ -809,3 +809,32 @@ int tdb_trans_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, return res; } + +/**************************************************************************** + tdb_delete, wrapped in a transaction. This way we make sure that a process + that dies within deleting does not leave a corrupt tdb behind. +****************************************************************************/ + +int tdb_trans_delete(struct tdb_context *tdb, TDB_DATA key) +{ + int res; + + if ((res = tdb_transaction_start(tdb)) != 0) { + DEBUG(5, ("tdb_transaction_start failed\n")); + return res; + } + + if ((res = tdb_delete(tdb, key)) != 0) { + DEBUG(10, ("tdb_delete failed\n")); + if (tdb_transaction_cancel(tdb) != 0) { + smb_panic("Cancelling transaction failed\n"); + } + return res; + } + + if ((res = tdb_transaction_commit(tdb)) != 0) { + DEBUG(5, ("tdb_transaction_commit failed\n")); + } + + return res; +} -- cgit