]> git.ozlabs.org Git - ccan/commitdiff
tdb: use tdb_nest_lock() for seqnum lock.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 22 Feb 2010 03:48:32 +0000 (14:18 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 22 Feb 2010 03:48:32 +0000 (14:18 +1030)
This is pure overhead, but it centralizes the locking.  Realloc (esp. as
most implementations are lazy) is fast compared to the fnctl anyway.

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

index 2da4428230971f8602e9536d7a7af2abf69e404a..ede0027564099aa44bf501ce1097f030d66dd0c2 100644 (file)
@@ -59,14 +59,14 @@ static void tdb_increment_seqnum(struct tdb_context *tdb)
                return;
        }
 
-       if (tdb_brlock(tdb, F_WRLCK, TDB_SEQNUM_OFS, 1,
-                      TDB_LOCK_WAIT|TDB_LOCK_PROBE) != 0) {
+       if (tdb_nest_lock(tdb, TDB_SEQNUM_OFS, F_WRLCK,
+                         TDB_LOCK_WAIT|TDB_LOCK_PROBE) != 0) {
                return;
        }
 
        tdb_increment_seqnum_nonblock(tdb);
 
-       tdb_brunlock(tdb, F_WRLCK, TDB_SEQNUM_OFS, 1);
+       tdb_nest_unlock(tdb, TDB_SEQNUM_OFS, F_WRLCK, false);
 }
 
 static int tdb_key_compare(TDB_DATA key, TDB_DATA data, void *private_data)