]> git.ozlabs.org Git - ccan/commit
tdb: tdb_allrecord_lock/tdb_allrecord_unlock/tdb_allrecord_upgrade
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 22 Feb 2010 04:02:13 +0000 (14:32 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 22 Feb 2010 04:02:13 +0000 (14:32 +1030)
commit88541fe7eb0542150669312675ddc00e9684de66
tree053d8aae8a2065e86c88ce1e25829f6b51bcd520
parentbbf2f9cef4bdbb3841869e9b87f234886985f7e8
tdb: tdb_allrecord_lock/tdb_allrecord_unlock/tdb_allrecord_upgrade

Centralize locking of all chains of the tdb; rename _tdb_lockall to
tdb_allrecord_lock and _tdb_unlockall to tdb_allrecord_unlock, and
tdb_brlock_upgrade to tdb_allrecord_upgrade.

Then we use this in the transaction code.  Unfortunately, if the transaction
code records that it has grabbed the allrecord lock read-only, write locks
will fail, so we treat this upgradable lock as a write lock, and mark it
as upgradable using the otherwise-unused offset field.

One subtlety: now the transaction code is using the allrecord_lock, the
tdb_release_extra_locks() function drops it for us, so we no longer need
to do it manually in _tdb_transaction_cancel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/tdb/lock.c
ccan/tdb/tdb_private.h
ccan/tdb/transaction.c