summaryrefslogtreecommitdiff
path: root/lib/ntdb/ntdb.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/ntdb.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/ntdb.c')
-rw-r--r--lib/ntdb/ntdb.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/ntdb/ntdb.c b/lib/ntdb/ntdb.c
index ddbf7d6e9e..6c75915899 100644
--- a/lib/ntdb/ntdb.c
+++ b/lib/ntdb/ntdb.c
@@ -234,7 +234,7 @@ out:
}
_PUBLIC_ enum NTDB_ERROR ntdb_fetch(struct ntdb_context *ntdb, NTDB_DATA key,
- NTDB_DATA *data)
+ NTDB_DATA *data)
{
ntdb_off_t off;
struct ntdb_used_record rec;
@@ -353,9 +353,15 @@ _PUBLIC_ void ntdb_add_flag(struct ntdb_context *ntdb, unsigned flag)
ntdb->flags |= NTDB_NOLOCK;
break;
case NTDB_NOMMAP:
+ if (ntdb->file->direct_count) {
+ ntdb_logerr(ntdb, NTDB_ERR_EINVAL, NTDB_LOG_USE_ERROR,
+ "ntdb_add_flag: Can't get NTDB_NOMMAP from"
+ " ntdb_parse_record!");
+ return;
+ }
ntdb->flags |= NTDB_NOMMAP;
#ifndef HAVE_INCOHERENT_MMAP
- ntdb_munmap(ntdb->file);
+ ntdb_munmap(ntdb);
#endif
break;
case NTDB_NOSYNC: