diff options
Diffstat (limited to 'util/mmap_win.cpp')
-rw-r--r-- | util/mmap_win.cpp | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/util/mmap_win.cpp b/util/mmap_win.cpp index 9173d7b..71bcceb 100644 --- a/util/mmap_win.cpp +++ b/util/mmap_win.cpp @@ -20,6 +20,7 @@ #include "text.h" #include "../db/mongommf.h" #include "../db/concurrency.h" +#include "timer.h" namespace mongo { @@ -166,13 +167,39 @@ namespace mongo { scoped_lock lk(*_flushMutex); - bool success = FlushViewOfFile(_view, 0); // 0 means whole mapping - if (!success) { - int err = GetLastError(); - out() << "FlushViewOfFile failed " << err << " file: " << _filename << endl; + int loopCount = 0; + bool success = false; + bool timeout = false; + int dosError = ERROR_SUCCESS; + const int maximumLoopCount = 1000 * 1000; + const int maximumTimeInSeconds = 60; + Timer t; + while ( !success && !timeout && loopCount < maximumLoopCount ) { + ++loopCount; + success = FALSE != FlushViewOfFile( _view, 0 ); + if ( !success ) { + dosError = GetLastError(); + if ( dosError != ERROR_LOCK_VIOLATION ) { + break; + } + timeout = t.seconds() > maximumTimeInSeconds; + } + } + if ( success && loopCount > 1 ) { + log() << "FlushViewOfFile for " << _filename + << " succeeded after " << loopCount + << " attempts taking " << t.millis() + << " ms" << endl; + } + else if ( !success ) { + log() << "FlushViewOfFile for " << _filename + << " failed with error " << dosError + << " after " << loopCount + << " attempts taking " << t.millis() + << " ms" << endl; } - success = FlushFileBuffers(_fd); + success = FALSE != FlushFileBuffers(_fd); if (!success) { int err = GetLastError(); out() << "FlushFileBuffers failed " << err << " file: " << _filename << endl; |