summaryrefslogtreecommitdiff
path: root/lib/ntdb/open.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2012-06-22 09:44:40 +0930
committerRusty Russell <rusty@rustcorp.com.au>2012-06-22 07:35:17 +0200
commit0a34f342c3facace0767ff08f05532c9f161e305 (patch)
treec227f755f1933e797ac49f74a856c8d60b11539d /lib/ntdb/open.c
parent66d151d6893657b31c419d422bffeefc506e2319 (diff)
downloadsamba-0a34f342c3facace0767ff08f05532c9f161e305.tar.gz
samba-0a34f342c3facace0767ff08f05532c9f161e305.tar.bz2
samba-0a34f342c3facace0767ff08f05532c9f161e305.zip
ntdb: enhancement to allow direct access to the ntdb map during expansion.
This means keeping the old mmap around when we expand the database. We could revert to read/write, except for platforms with incoherent mmap (ie. OpenBSD), where we need to use mmap for all accesses. Thus we keep a linked list of old maps, and unmap them when the last access finally goes away. This is required if we want ntdb_parse_record() callbacks to be able to expand the database. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/ntdb/open.c')
-rw-r--r--lib/ntdb/open.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/ntdb/open.c b/lib/ntdb/open.c
index 56c97afe43..abec117236 100644
--- a/lib/ntdb/open.c
+++ b/lib/ntdb/open.c
@@ -99,7 +99,6 @@ static void ntdb_context_init(struct ntdb_context *ntdb)
{
/* Initialize the NTDB fields here */
ntdb_io_init(ntdb);
- ntdb->direct_access = 0;
ntdb->transaction = NULL;
ntdb->access = NULL;
}
@@ -259,6 +258,8 @@ static enum NTDB_ERROR ntdb_new_file(struct ntdb_context *ntdb)
ntdb->file->allrecord_lock.count = 0;
ntdb->file->refcnt = 1;
ntdb->file->map_ptr = NULL;
+ ntdb->file->direct_count = 0;
+ ntdb->file->old_mmaps = NULL;
return NTDB_SUCCESS;
}
@@ -841,7 +842,7 @@ fail_errno:
ntdb->free_fn(ntdb->file->map_ptr,
ntdb->alloc_data);
} else
- ntdb_munmap(ntdb->file);
+ ntdb_munmap(ntdb);
}
if (ntdb->file->fd != -1 && close(ntdb->file->fd) != 0)
ntdb_logerr(ntdb, NTDB_ERR_IO, NTDB_LOG_ERROR,
@@ -875,7 +876,7 @@ _PUBLIC_ int ntdb_close(struct ntdb_context *ntdb)
ntdb->free_fn(ntdb->file->map_ptr,
ntdb->alloc_data);
} else {
- ntdb_munmap(ntdb->file);
+ ntdb_munmap(ntdb);
}
}
ret = close(ntdb->file->fd);