From 639c39189fefbab21580e10695289e44cbb65bc2 Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Wed, 10 Mar 2010 13:39:37 -0500 Subject: fsync shouldn't be a noop on windows SERVER-728 (backport to 1.2) (cherry picked from commit ae02e6101528a5f748da95ce6abbed5c6499bcaf) --- util/mmap_win.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/util/mmap_win.cpp b/util/mmap_win.cpp index b48bb156c53..bbb7d873986 100644 --- a/util/mmap_win.cpp +++ b/util/mmap_win.cpp @@ -99,7 +99,22 @@ namespace mongo { return view; } - void MemoryMappedFile::flush(bool) { - } + void MemoryMappedFile::flush(bool sync) { + if (!view) return; + + // Note: this is blocking and ignores sync + bool success = FlushViewOfFile(view, 0); // 0 means whole mapping + if (!success){ + int err = GetLastError(); + out() << "FlushViewOfFile failed " << err << " " << endl; + } + if (sync){ + bool success = FlushFileBuffers(fd); + if (!success){ + int err = GetLastError(); + out() << "FlushFileBuffers failed " << err << " " << endl; + } + } + } } -- cgit v1.2.1