summaryrefslogtreecommitdiffstats
path: root/ctdb/lib/tdb/common/lock.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2010-04-22 13:54:05 +0930
committerRusty Russell <rusty@rustcorp.com.au>2010-04-22 13:54:05 +0930
commitfa782ab9923b40ec07bcc68d38aa34dea7c01187 (patch)
treee7169af361c66ca304ea73176d43bad032ade58a /ctdb/lib/tdb/common/lock.c
parent80376a79930f43047806271512f813aabc6a3297 (diff)
downloadsamba-fa782ab9923b40ec07bcc68d38aa34dea7c01187.tar.gz
samba-fa782ab9923b40ec07bcc68d38aa34dea7c01187.tar.xz
samba-fa782ab9923b40ec07bcc68d38aa34dea7c01187.zip
tdb: rename tdb_release_extra_locks() to tdb_release_transaction_locks()
tdb_release_extra_locks() is too general: it carefully skips over the transaction lock, even though the only caller then drops it. Change this, and rename it to show it's clearly transaction-specific. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from commit a84222bbaf9ed2c7b9c61b8157b2e3c85f17fa32) (This used to be ctdb commit 803035716338170896fee15f15b17c32e7ee777e)
Diffstat (limited to 'ctdb/lib/tdb/common/lock.c')
-rw-r--r--ctdb/lib/tdb/common/lock.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/ctdb/lib/tdb/common/lock.c b/ctdb/lib/tdb/common/lock.c
index 2a681efc99..193d1d8a0a 100644
--- a/ctdb/lib/tdb/common/lock.c
+++ b/ctdb/lib/tdb/common/lock.c
@@ -719,11 +719,10 @@ bool tdb_have_extra_locks(struct tdb_context *tdb)
return extra;
}
-/* The transaction code uses this to remove all locks. Note that this
- may include OPEN_LOCK. */
-void tdb_release_extra_locks(struct tdb_context *tdb)
+/* The transaction code uses this to remove all locks. */
+void tdb_release_transaction_locks(struct tdb_context *tdb)
{
- unsigned int i, extra = 0;
+ unsigned int i, active = 0;
if (tdb->allrecord_lock.count != 0) {
tdb_brunlock(tdb, tdb->allrecord_lock.ltype, FREELIST_TOP, 0);
@@ -733,16 +732,14 @@ void tdb_release_extra_locks(struct tdb_context *tdb)
for (i=0;i<tdb->num_lockrecs;i++) {
struct tdb_lock_type *lck = &tdb->lockrecs[i];
- /* Don't release transaction or active locks! */
- if (tdb->transaction && lck->off == TRANSACTION_LOCK) {
- tdb->lockrecs[extra++] = *lck;
- } else if (lck->off == ACTIVE_LOCK) {
- tdb->lockrecs[extra++] = *lck;
+ /* Don't release the active lock! Copy it to first entry. */
+ if (lck->off == ACTIVE_LOCK) {
+ tdb->lockrecs[active++] = *lck;
} else {
tdb_brunlock(tdb, lck->ltype, lck->off, 1);
}
}
- tdb->num_lockrecs = extra;
+ tdb->num_lockrecs = active;
if (tdb->num_lockrecs == 0) {
SAFE_FREE(tdb->lockrecs);
}