diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2011-09-14 07:56:13 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2011-09-14 07:56:13 +0930 |
commit | 9140fca812063be69842a6c64030e32c65c9dff1 (patch) | |
tree | 73b9e12160be66ce7853e0e9b44ad44c17269b65 /lib/tdb2/lock.c | |
parent | 30294c7b91456dd49b89a9b26eb0b1066087815c (diff) | |
download | samba-9140fca812063be69842a6c64030e32c65c9dff1.tar.gz samba-9140fca812063be69842a6c64030e32c65c9dff1.tar.bz2 samba-9140fca812063be69842a6c64030e32c65c9dff1.zip |
tdb2: unify tdb1_chainlock et al. into tdb_chainlock
Switch on the TDB_VERSION1 flag.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit ceb2f3eacbad917ee990afbc3dd800bfb0607887)
Diffstat (limited to 'lib/tdb2/lock.c')
-rw-r--r-- | lib/tdb2/lock.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/tdb2/lock.c b/lib/tdb2/lock.c index bd896a35e0..7d4311c8e5 100644 --- a/lib/tdb2/lock.c +++ b/lib/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; i<tdb->file->num_lockrecs; i++) { |