diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2010-02-24 12:42:24 +1030 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2010-02-24 12:42:24 +1030 |
commit | dd1b508c63034452673dbfee9956f52a1b6c90a5 (patch) | |
tree | f3ab296a0f442a8068dd236e6de7ed65330b3cca /lib/tdb/common | |
parent | fca1621965c547e2d076eca2a2599e9629f91266 (diff) | |
download | samba-dd1b508c63034452673dbfee9956f52a1b6c90a5.tar.gz samba-dd1b508c63034452673dbfee9956f52a1b6c90a5.tar.bz2 samba-dd1b508c63034452673dbfee9956f52a1b6c90a5.zip |
tdb: cleanup: remove ltype argument from _tdb_transaction_cancel.
Now the transaction allrecord lock is the standard one, and thus is cleaned
in tdb_release_extra_locks(), _tdb_transaction_cancel() doesn't need to
know what type it is.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/tdb/common')
-rw-r--r-- | lib/tdb/common/transaction.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/lib/tdb/common/transaction.c b/lib/tdb/common/transaction.c index c9718a59b3..0f9f80c86e 100644 --- a/lib/tdb/common/transaction.c +++ b/lib/tdb/common/transaction.c @@ -577,8 +577,7 @@ static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t } -/* ltype is F_WRLCK after prepare. */ -static int _tdb_transaction_cancel(struct tdb_context *tdb, int ltype) +static int _tdb_transaction_cancel(struct tdb_context *tdb) { int i, ret = 0; @@ -633,11 +632,8 @@ static int _tdb_transaction_cancel(struct tdb_context *tdb, int ltype) */ int tdb_transaction_cancel(struct tdb_context *tdb) { - int ltype = F_RDLCK; tdb_trace(tdb, "tdb_transaction_cancel"); - if (tdb->transaction && tdb->transaction->prepared) - ltype = F_WRLCK; - return _tdb_transaction_cancel(tdb, ltype); + return _tdb_transaction_cancel(tdb); } /* @@ -903,14 +899,14 @@ static int _tdb_transaction_prepare_commit(struct tdb_context *tdb) if (tdb->transaction->prepared) { tdb->ecode = TDB_ERR_EINVAL; - _tdb_transaction_cancel(tdb, F_WRLCK); + _tdb_transaction_cancel(tdb); TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_prepare_commit: transaction already prepared\n")); return -1; } if (tdb->transaction->transaction_error) { tdb->ecode = TDB_ERR_IO; - _tdb_transaction_cancel(tdb, F_RDLCK); + _tdb_transaction_cancel(tdb); TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_prepare_commit: transaction error pending\n")); return -1; } @@ -932,14 +928,14 @@ static int _tdb_transaction_prepare_commit(struct tdb_context *tdb) if (tdb_have_extra_locks(tdb)) { tdb->ecode = TDB_ERR_LOCK; TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_prepare_commit: locks pending on commit\n")); - _tdb_transaction_cancel(tdb, F_RDLCK); + _tdb_transaction_cancel(tdb); return -1; } /* upgrade the main transaction lock region to a write lock */ if (tdb_allrecord_upgrade(tdb) == -1) { TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_prepare_commit: failed to upgrade hash locks\n")); - _tdb_transaction_cancel(tdb, F_RDLCK); + _tdb_transaction_cancel(tdb); return -1; } @@ -947,7 +943,7 @@ static int _tdb_transaction_prepare_commit(struct tdb_context *tdb) during the commit */ if (tdb_nest_lock(tdb, OPEN_LOCK, F_WRLCK, TDB_LOCK_WAIT) == -1) { TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_prepare_commit: failed to get open lock\n")); - _tdb_transaction_cancel(tdb, F_WRLCK); + _tdb_transaction_cancel(tdb); return -1; } @@ -955,7 +951,7 @@ static int _tdb_transaction_prepare_commit(struct tdb_context *tdb) /* write the recovery data to the end of the file */ if (transaction_setup_recovery(tdb, &tdb->transaction->magic_offset) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_prepare_commit: failed to setup recovery data\n")); - _tdb_transaction_cancel(tdb, F_WRLCK); + _tdb_transaction_cancel(tdb); return -1; } } @@ -969,7 +965,7 @@ static int _tdb_transaction_prepare_commit(struct tdb_context *tdb) tdb->transaction->old_map_size) == -1) { tdb->ecode = TDB_ERR_IO; TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_prepare_commit: expansion failed\n")); - _tdb_transaction_cancel(tdb, F_WRLCK); + _tdb_transaction_cancel(tdb); return -1; } tdb->map_size = tdb->transaction->old_map_size; @@ -1008,7 +1004,7 @@ int tdb_transaction_commit(struct tdb_context *tdb) if (tdb->transaction->transaction_error) { tdb->ecode = TDB_ERR_IO; - _tdb_transaction_cancel(tdb, F_RDLCK); + _tdb_transaction_cancel(tdb); TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_commit: transaction error pending\n")); return -1; } @@ -1021,7 +1017,7 @@ int tdb_transaction_commit(struct tdb_context *tdb) /* check for a null transaction */ if (tdb->transaction->blocks == NULL) { - _tdb_transaction_cancel(tdb, F_RDLCK); + _tdb_transaction_cancel(tdb); return 0; } @@ -1057,7 +1053,7 @@ int tdb_transaction_commit(struct tdb_context *tdb) tdb->methods = methods; tdb_transaction_recover(tdb); - _tdb_transaction_cancel(tdb, F_WRLCK); + _tdb_transaction_cancel(tdb); TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: write failed\n")); return -1; @@ -1092,7 +1088,7 @@ int tdb_transaction_commit(struct tdb_context *tdb) /* use a transaction cancel to free memory and remove the transaction locks */ - _tdb_transaction_cancel(tdb, F_WRLCK); + _tdb_transaction_cancel(tdb); if (need_repack) { return tdb_repack(tdb); |