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
commit66d151d6893657b31c419d422bffeefc506e2319 (patch)
tree34d217715da0890571eda70fcfc67455ef1660d4 /lib/ntdb/open.c
parent406bd2d121c3eeef7c3bb6bc74c7a6ccbe296c38 (diff)
downloadsamba-66d151d6893657b31c419d422bffeefc506e2319.tar.gz
samba-66d151d6893657b31c419d422bffeefc506e2319.tar.bz2
samba-66d151d6893657b31c419d422bffeefc506e2319.zip
ntdb: don't munmap the database on every close.
Since we can have multiple openers, we should leave the mmap in place for the other openers to use. Enhance the test to check the bug (it still works, because without mmap we fall back to read/write, but performance would be terrible!). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/ntdb/open.c')
-rw-r--r--lib/ntdb/open.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/ntdb/open.c b/lib/ntdb/open.c
index 9de9e9b48c..56c97afe43 100644
--- a/lib/ntdb/open.c
+++ b/lib/ntdb/open.c
@@ -868,19 +868,19 @@ _PUBLIC_ int ntdb_close(struct ntdb_context *ntdb)
ntdb_transaction_cancel(ntdb);
}
- if (ntdb->file->map_ptr) {
- if (ntdb->flags & NTDB_INTERNAL)
- ntdb->free_fn(ntdb->file->map_ptr, ntdb->alloc_data);
- else
- ntdb_munmap(ntdb->file);
- }
- if (ntdb->file) {
- ntdb_lock_cleanup(ntdb);
- if (--ntdb->file->refcnt == 0) {
- ret = close(ntdb->file->fd);
- ntdb->free_fn(ntdb->file->lockrecs, ntdb->alloc_data);
- ntdb->free_fn(ntdb->file, ntdb->alloc_data);
+ ntdb_lock_cleanup(ntdb);
+ if (--ntdb->file->refcnt == 0) {
+ if (ntdb->file->map_ptr) {
+ if (ntdb->flags & NTDB_INTERNAL) {
+ ntdb->free_fn(ntdb->file->map_ptr,
+ ntdb->alloc_data);
+ } else {
+ ntdb_munmap(ntdb->file);
+ }
}
+ ret = close(ntdb->file->fd);
+ ntdb->free_fn(ntdb->file->lockrecs, ntdb->alloc_data);
+ ntdb->free_fn(ntdb->file, ntdb->alloc_data);
}
/* Remove from tdbs list */