]> git.ozlabs.org Git - ccan/commit
tdb: cleanup: tdb_nest_lock/tdb_nest_unlock
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 22 Feb 2010 03:03:27 +0000 (13:33 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 22 Feb 2010 03:03:27 +0000 (13:33 +1030)
commitacf1a21e440b2908df0ce57c48dab1aca9e23cad
tree12ef68aaa4f32080754afb24b2b5ca23f1cbdad6
parent1d03cc6df3b4f5c8174096ae3411527f266f9a97
tdb: cleanup: tdb_nest_lock/tdb_nest_unlock

Because fcntl locks don't nest, we track them in the tdb->lockrecs array
and only place/release them when the count goes to 1/0.  We only do this
for record locks, so we simply place the list number (or -1 for the free
list) in the structure.

To generalize this:

1) Put the offset rather than list number in struct tdb_lock_type.
2) Rename _tdb_lock() to tdb_nest_lock, make it non-static and move the
   allrecord check out to the callers (except the mark case which doesn't
   care).
3) Rename _tdb_unlock() to tdb_nest_unlock(), make it non-static and
   move the allrecord out to the callers (except mark again).

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