The msync manpage reports that msync *must* be called before munmap. Failure to do...
authorSimo Sorce <idra@samba.org>
Wed, 3 Sep 2008 14:44:09 +0000 (10:44 -0400)
committerSimo Sorce <idra@samba.org>
Wed, 3 Sep 2008 18:35:09 +0000 (14:35 -0400)
source/tdb/common/io.c
source/tdb/common/transaction.c

index 4b7e33ab65992fee9cf1611338084abd8dba0bfd..df6681674d088a753b0de54229e9fe36c432d664 100644 (file)
@@ -190,7 +190,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;
        }
index 8bda651f1e44b2081bd5e7ec0f26211ee054b935..50d6534d0f6483486d03bb480322aa6cfbb7b469 100644 (file)
@@ -551,7 +551,7 @@ static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t
                TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction: fsync failed\n"));
                return -1;
        }
-#ifdef MS_SYNC
+#ifdef HAVE_MMAP
        if (tdb->map_ptr) {
                tdb_off_t moffset = offset & ~(tdb->page_size-1);
                if (msync(moffset + (char *)tdb->map_ptr,