X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Flock.c;h=7d4311c8e568b8125d72d2e91ec3dd0c8b08d4b9;hp=bd896a35e0144d5b2db619598cabd0bf4ae62690;hb=3352e4e947777d4a90a2dd4f3037e1e494231b25;hpb=c8c3b3568677e8b0105f84e4ab068c580faf4591 diff --git a/ccan/tdb2/lock.c b/ccan/tdb2/lock.c index bd896a35..7d4311c8 100644 --- a/ccan/tdb2/lock.c +++ b/ccan/tdb2/lock.c @@ -534,6 +534,12 @@ enum TDB_ERROR tdb_allrecord_lock(struct tdb_context *tdb, int ltype, enum TDB_ERROR ecode; tdb_bool_err berr; + if (tdb->flags & TDB_VERSION1) { + if (tdb1_allrecord_lock(tdb, ltype, flags, upgradable) == -1) + return tdb->last_error; + return TDB_SUCCESS; + } + if (tdb->flags & TDB_NOLOCK) return TDB_SUCCESS; @@ -648,6 +654,11 @@ void tdb_unlock_expand(struct tdb_context *tdb, int ltype) /* unlock entire db */ void tdb_allrecord_unlock(struct tdb_context *tdb, int ltype) { + if (tdb->flags & TDB_VERSION1) { + tdb1_allrecord_unlock(tdb, ltype); + return; + } + if (tdb->flags & TDB_NOLOCK) return; @@ -862,12 +873,7 @@ void tdb_lock_cleanup(struct tdb_context *tdb) while (tdb->file->allrecord_lock.count && tdb->file->allrecord_lock.owner == tdb) { - if (tdb->flags & TDB_VERSION1) - tdb1_allrecord_unlock(tdb, - tdb->file->allrecord_lock.ltype); - else - tdb_allrecord_unlock(tdb, - tdb->file->allrecord_lock.ltype); + tdb_allrecord_unlock(tdb, tdb->file->allrecord_lock.ltype); } for (i=0; ifile->num_lockrecs; i++) {