summaryrefslogtreecommitdiff
path: root/source4/lib/tdb/common/io.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2008-09-03 10:44:09 -0400
committerStefan Metzmacher <metze@samba.org>2008-09-14 19:19:55 +0200
commitb39e332bd7803dd4ce8267f750c497b5deb837ee (patch)
treecbe26fb11060805d4d724a44a256efd9dbe200e0 /source4/lib/tdb/common/io.c
parent8c88209c6f4b57b0dbe1459bd5bc583c5d321758 (diff)
downloadsamba-b39e332bd7803dd4ce8267f750c497b5deb837ee.tar.gz
samba-b39e332bd7803dd4ce8267f750c497b5deb837ee.tar.bz2
samba-b39e332bd7803dd4ce8267f750c497b5deb837ee.zip
The msync manpage reports that msync *must* be called before munmap. Failure to do so may result in lost data. Fix an ifdef check, I really think we meant to check HAVE_MMAP here.
(cherry picked from commit 74c8575b3f3b90ea21ae6aa7ccd95947838af956) (This used to be commit 8fd54bb55f0c23bd025d1719abcbe75c6a2ea8ac)
Diffstat (limited to 'source4/lib/tdb/common/io.c')
-rw-r--r--source4/lib/tdb/common/io.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/source4/lib/tdb/common/io.c b/source4/lib/tdb/common/io.c
index 172ab69d8c..4ec18de48e 100644
--- a/source4/lib/tdb/common/io.c
+++ b/source4/lib/tdb/common/io.c
@@ -189,7 +189,13 @@ int tdb_munmap(struct tdb_context *tdb)
#ifdef HAVE_MMAP
if (tdb->map_ptr) {
- int ret = munmap(tdb->map_ptr, tdb->map_size);
+ int ret;
+
+ ret = msync(tdb->map_ptr, tdb->map_size, MS_SYNC);
+ if (ret != 0)
+ return ret;
+
+ ret = munmap(tdb->map_ptr, tdb->map_size);
if (ret != 0)
return ret;
}