The msync manpage reports that msync *must* be called before munmap. Failure to do...
[samba.git] / source4 / lib / tdb / common / io.c
index 172ab69d8c9e69ae7f160071567c4d885ac7848c..4ec18de48e043cd1e764dd9053922fc257d9404c 100644 (file)
@@ -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;
        }