summaryrefslogtreecommitdiff
path: root/util/mmap_win.cpp
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2012-05-10 06:57:54 +0200
committerAntonin Kral <a.kral@bobek.cz>2012-05-10 06:57:54 +0200
commit61619b3142c1de8f60f91964ff2656054d4f11a6 (patch)
treed3aaf9d1e70cac8efa0856e5b5ba39e2fb9dc526 /util/mmap_win.cpp
parenteaaa7b30c99b89b5483e0a372bb73fe8c8695185 (diff)
downloadmongodb-61619b3142c1de8f60f91964ff2656054d4f11a6.tar.gz
Imported Upstream version 2.0.5
Diffstat (limited to 'util/mmap_win.cpp')
-rw-r--r--util/mmap_win.cpp37
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;