From 4fd7cf1dc05f9eea763214214c88d899dec7e11c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 16 Jul 2009 18:07:14 +0930 Subject: [PATCH] Handle global_lock properly in tdb_transaction_lock/unlock. --- ccan/tdb/lock.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ccan/tdb/lock.c b/ccan/tdb/lock.c index 117596a3..bcd560d7 100644 --- a/ccan/tdb/lock.c +++ b/ccan/tdb/lock.c @@ -301,7 +301,10 @@ int tdb_unlock(struct tdb_context *tdb, int list, int ltype) */ int tdb_transaction_lock(struct tdb_context *tdb, int ltype) { - if (tdb->have_transaction_lock || tdb->global_lock.count) { + if (tdb->global_lock.count) { + return 0; + } + if (tdb->have_transaction_lock) { tdb->have_transaction_lock++; return 0; } @@ -320,6 +323,9 @@ int tdb_transaction_lock(struct tdb_context *tdb, int ltype) */ int tdb_transaction_unlock(struct tdb_context *tdb) { + if (tdb->global_lock.count) { + return 0; + } if (--tdb->have_transaction_lock) { return 0; } -- 2.39.2