tdb: fix locking error
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 21 Jul 2009 06:53:35 +0000 (16:23 +0930)
committerMichael Adam <obnox@samba.org>
Tue, 21 Jul 2009 08:21:53 +0000 (10:21 +0200)
54a51839ea65aa788b18fce8de0ae4f9ba63e4e7 "Make tdb transaction lock
recursive (samba version)" was broken: I "cleaned it up" and prevented
it from ever unlocking.

To see the problem:
$ bin/tdbtorture -s 1248142523
tdb_brlock failed (fd=3) at offset 8 rw_type=1 lck_type=14 len=1
tdb_transaction_lock: failed to get transaction lock
tdb_transaction_start failed: Resource deadlock avoided

My testcase relied on the *count* being correct, which it was.  Fixing that
now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Michael Adam <obnox@samba.org>
lib/tdb/common/lock.c

index d812fbfdc5e6e3e03775314fe01e517627a78830..2c72ae1f0de1c5097afe8f54d27a04d7816e432a 100644 (file)
@@ -328,7 +328,7 @@ int tdb_transaction_unlock(struct tdb_context *tdb)
        if (tdb->global_lock.count) {
                return 0;
        }
-       if (tdb->transaction_lock_count > 0) {
+       if (tdb->transaction_lock_count > 1) {
                tdb->transaction_lock_count--;
                return 0;
        }