]> git.ozlabs.org Git - ccan/commitdiff
Handle global_lock properly in tdb_transaction_lock/unlock.
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 16 Jul 2009 08:37:14 +0000 (18:07 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 16 Jul 2009 08:37:14 +0000 (18:07 +0930)
ccan/tdb/lock.c

index 117596a3f203814daa9e4611d96b1216de050643..bcd560d792231ff2defce3430cf6feb7117fa243 100644 (file)
@@ -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;
        }