From d6bcf91f2f504298e8149c9b5523a79561ede075 Mon Sep 17 00:00:00 2001 From: dwight Date: Wed, 9 Feb 2011 11:34:20 -0500 Subject: on an open failure close handles faster, that should be safer --- util/mmap_win.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/mmap_win.cpp b/util/mmap_win.cpp index 19a5b1bbf7b..5bbf49b5649 100644 --- a/util/mmap_win.cpp +++ b/util/mmap_win.cpp @@ -97,6 +97,7 @@ namespace mongo { } void* MemoryMappedFile::map(const char *filenameIn, unsigned long long &length, int options) { + assert( fd == 0 && len == 0 ); // can't open more than once setFilename(filenameIn); /* big hack here: Babble uses db names with colons. doesn't seem to work on windows. temporary perhaps. */ char filename[256]; @@ -147,6 +148,7 @@ namespace mongo { if ( maphandle == NULL ) { DWORD e = GetLastError(); // log() call was killing lasterror before we get to that point in the stream log() << "CreateFileMapping failed " << filename << ' ' << errnoWithDescription(e) << endl; + close(); return 0; } } @@ -160,6 +162,7 @@ namespace mongo { if ( view == 0 ) { DWORD e = GetLastError(); log() << "MapViewOfFile failed " << filename << " " << errnoWithDescription(e) << endl; + close(); } else { views.push_back(view); -- cgit v1.2.1