diff options
author | Antonin Kral <a.kral@bobek.cz> | 2012-05-10 06:57:54 +0200 |
---|---|---|
committer | Antonin Kral <a.kral@bobek.cz> | 2012-05-10 06:57:54 +0200 |
commit | 61619b3142c1de8f60f91964ff2656054d4f11a6 (patch) | |
tree | d3aaf9d1e70cac8efa0856e5b5ba39e2fb9dc526 /util/mmap_win.cpp | |
parent | eaaa7b30c99b89b5483e0a372bb73fe8c8695185 (diff) | |
download | mongodb-61619b3142c1de8f60f91964ff2656054d4f11a6.tar.gz |
Imported Upstream version 2.0.5
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; |