summaryrefslogtreecommitdiff
path: root/source4/lib/tdb/common/traverse.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-09-24 03:43:02 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:38:49 -0500
commit5860aef9cd53da572bef1b86a62a3a5e86da84b0 (patch)
treeceef07b8fdd5763db9077d157351f5bc58a3d761 /source4/lib/tdb/common/traverse.c
parent5a770bf72061e6b57f88e28fc585ff3c015ace49 (diff)
downloadsamba-5860aef9cd53da572bef1b86a62a3a5e86da84b0.tar.gz
samba-5860aef9cd53da572bef1b86a62a3a5e86da84b0.tar.bz2
samba-5860aef9cd53da572bef1b86a62a3a5e86da84b0.zip
r10465: separate out a read_only db from a read-only traversal to ensure we
don't end up doing a mmap read only (This used to be commit 294ccfd46a0c4e1af9365d028acdabec03c41ad3)
Diffstat (limited to 'source4/lib/tdb/common/traverse.c')
-rw-r--r--source4/lib/tdb/common/traverse.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/source4/lib/tdb/common/traverse.c b/source4/lib/tdb/common/traverse.c
index f8315f5770..9271b75aa8 100644
--- a/source4/lib/tdb/common/traverse.c
+++ b/source4/lib/tdb/common/traverse.c
@@ -114,7 +114,7 @@ static int tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock *tloc
/* Try to clean dead ones from old traverses */
current = tlock->off;
tlock->off = rec->next;
- if (!tdb->read_only &&
+ if (!(tdb->read_only || tdb->traverse_read) &&
tdb_do_delete(tdb, current, rec) != 0)
goto fail;
}
@@ -204,10 +204,10 @@ int tdb_traverse_read(struct tdb_context *tdb,
tdb_traverse_func fn, void *private)
{
struct tdb_traverse_lock tl = { NULL, 0, 0, F_RDLCK };
- int ret, read_only = tdb->read_only;
- tdb->read_only = 1;
+ int ret;
+ tdb->traverse_read++;
ret = tdb_traverse_internal(tdb, fn, private, &tl);
- tdb->read_only = read_only;
+ tdb->traverse_read--;
return ret;
}
@@ -221,7 +221,7 @@ int tdb_traverse(struct tdb_context *tdb,
struct tdb_traverse_lock tl = { NULL, 0, 0, F_WRLCK };
int ret;
- if (tdb->read_only) {
+ if (tdb->read_only || tdb->traverse_read) {
return tdb_traverse_read(tdb, fn, private);
}