X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb%2Flock.c;h=bcd560d792231ff2defce3430cf6feb7117fa243;hp=6809ce37d87513986cc54fab82251004379557cb;hb=f26355f247709f0150028ec48df7d3f2af463423;hpb=010c8d465aa1e8810bd060ecf5d124ca2d990b0e diff --git a/ccan/tdb/lock.c b/ccan/tdb/lock.c index 6809ce37..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; } @@ -500,7 +506,7 @@ int tdb_chainlock_unmark(struct tdb_context *tdb, TDB_DATA key) int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key) { - tdb_trace_1rec(tdb, "tdb_chainlock", key); + tdb_trace_1rec(tdb, "tdb_chainunlock", key); return tdb_unlock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK); }