summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordwight <dwight@10gen.com>2011-02-09 11:34:20 -0500
committerdwight <dwight@10gen.com>2011-02-09 13:08:00 -0500
commitd6bcf91f2f504298e8149c9b5523a79561ede075 (patch)
tree0853ebb0c086208f2ecaf774e3b50ae59fd8c952
parent950da41582217ef4a815fe45af1a8510cd0037f5 (diff)
downloadmongo-d6bcf91f2f504298e8149c9b5523a79561ede075.tar.gz
on an open failure close handles faster, that should be safer
-rw-r--r--util/mmap_win.cpp3
1 files changed, 3 insertions, 0 deletions
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);