diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2010-02-24 10:45:26 +1030 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2010-02-24 10:45:26 +1030 |
commit | caaf5c6baa1a4f340c1f38edd99b3a8b56621b8b (patch) | |
tree | 10f06ea7ed2c67440fa91899825dce445932ecfd /lib/tdb/common | |
parent | 9341f230f8968b4b18e451d15dda5ccbe7787768 (diff) | |
download | samba-caaf5c6baa1a4f340c1f38edd99b3a8b56621b8b.tar.gz samba-caaf5c6baa1a4f340c1f38edd99b3a8b56621b8b.tar.bz2 samba-caaf5c6baa1a4f340c1f38edd99b3a8b56621b8b.zip |
tdb: suppress record write locks when allrecord lock is taken.
Records themselves get (read) locked by the traversal code against delete.
Interestingly, this locking isn't done when the allrecord lock has been
taken, though the allrecord lock until recently didn't cover the actual
records (it now goes to end of file).
The write record lock, grabbed by the delete code, is not suppressed
by the allrecord lock. This is now bad: it causes us to punch a hole
in the allrecord lock when we release the write record lock. Make this
consistent: *no* record locks of any kind when the allrecord lock is
taken.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/tdb/common')
-rw-r--r-- | lib/tdb/common/lock.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/tdb/common/lock.c b/lib/tdb/common/lock.c index b1153b2e6f..8401cb7f8f 100644 --- a/lib/tdb/common/lock.c +++ b/lib/tdb/common/lock.c @@ -631,11 +631,20 @@ int tdb_write_lock_record(struct tdb_context *tdb, tdb_off_t off) for (i = &tdb->travlocks; i; i = i->next) if (i->off == off) return -1; + if (tdb->allrecord_lock.count) { + if (tdb->allrecord_lock.ltype == F_WRLCK) { + return 0; + } + return -1; + } return tdb->methods->brlock(tdb, F_WRLCK, off, 1, TDB_LOCK_NOWAIT|TDB_LOCK_PROBE); } int tdb_write_unlock_record(struct tdb_context *tdb, tdb_off_t off) { + if (tdb->allrecord_lock.count) { + return 0; + } return tdb->methods->brunlock(tdb, F_WRLCK, off, 1); } |