[PATCH] Make tdb transaction lock recursive (samba version)

Rusty Russell rusty at rustcorp.com.au
Tue Jul 21 00:53:35 MDT 2009

On Tue, 21 Jul 2009 10:07:26 am Tim Prouty wrote:
> On Jul 20, 2009, at 1:20 PM, Michael Adam wrote:
> > Pushed to master - thanks!
> I haven't looked at this patch, but running make test from a source3
> merged-build with this patch causes smbd to hang in fcntl for me.

Subject: tdb: fix locking error 

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

Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

diff --git a/lib/tdb/common/lock.c b/lib/tdb/common/lock.c
index d812fbf..326d38e 100644
--- a/lib/tdb/common/lock.c
+++ b/lib/tdb/common/lock.c
@@ -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) {
 		return 0;

More information about the samba-technical mailing list