From c64cd552c404f74f4f7e6aa2b4e1a6856c617011 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 Sep 2001 21:17:58 +0000 Subject: Fixed a couple of nasty bugs only easily seen with no mmap. Firstly, map_ptr not neccessarily set to NULL if no mmap, secondly, iterating through a tdb was using SETLK, instead of SETLKW - would almost never fail with mmap as the time holding the lock was so short, but was easily seen with read/write. One finaly bug needs tracking down w.r.t. traversal...... Jeremy. (This used to be commit 313c2e8652092a307165b6039dd7dfbbd0754ec3) --- source3/tdb/tdb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c index 5c116bcf7a..0207b00222 100644 --- a/source3/tdb/tdb.c +++ b/source3/tdb/tdb.c @@ -108,6 +108,8 @@ static void tdb_mmap(TDB_CONTEXT *tdb) TDB_LOG((tdb, 2, "tdb_mmap failed for size %d (%s)\n", tdb->map_size, strerror(errno))); } + } else { + tdb->map_ptr = NULL; } #else tdb->map_ptr = NULL; @@ -994,11 +996,11 @@ static int write_lock_record(TDB_CONTEXT *tdb, tdb_off off) for (i = &tdb->travlocks; i; i = i->next) if (i->off == off) return -1; - return tdb_brlock(tdb, off, F_WRLCK, F_SETLK, 1); + return tdb_brlock(tdb, off, F_WRLCK, F_SETLKW, 1); } static int write_unlock_record(TDB_CONTEXT *tdb, tdb_off off) { - return tdb_brlock(tdb, off, F_UNLCK, F_SETLK, 0); + return tdb_brlock(tdb, off, F_UNLCK, F_SETLKW, 0); } /* fcntl locks don't stack: avoid unlocking someone else's */ static int unlock_record(TDB_CONTEXT *tdb, tdb_off off) -- cgit