From: Rusty Russell Date: Thu, 16 Jul 2009 08:37:14 +0000 (+0930) Subject: Handle global_lock properly in tdb_transaction_lock/unlock. X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=4fd7cf1dc05f9eea763214214c88d899dec7e11c;p=ccan Handle global_lock properly in tdb_transaction_lock/unlock. --- 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; }