diff --git a/db/db.cpp b/db/db.cpp index db9e3914114..5a3677c5653 100644 --- a/db/db.cpp +++ b/db/db.cpp @@ -72,7 +72,8 @@ namespace mongo { out() << "quicktest()\n"; MemoryMappedFile mmf; - char *m = (char *) mmf.map("/tmp/quicktest", 16384); + int len = 16384; + char *m = (char *) mmf.map("/tmp/quicktest", len); // out() << "mmf reads: " << m << endl; strcpy_s(m, 1000, "hello worldz"); } diff --git a/db/namespace.cpp b/db/namespace.cpp index e97139f1428..0cde591bf6d 100644 --- a/db/namespace.cpp +++ b/db/namespace.cpp @@ -63,7 +63,7 @@ namespace mongo { i.dbDropped(); } - const int LEN = 16 * 1024 * 1024; + int LEN = 16 * 1024 * 1024; string pathString = path().string(); void *p = f.map(pathString.c_str(), LEN); if ( p == 0 ) { diff --git a/db/pdfile.cpp b/db/pdfile.cpp index bdf40b62094..e4ec701290c 100644 --- a/db/pdfile.cpp +++ b/db/pdfile.cpp @@ -248,7 +248,6 @@ namespace mongo { uassert("can't map file memory - mongo requires 64 bit build for larger datasets", header); else uassert("can't map file memory", header); - // If opening an existing file, this is a no-op. header->init(fileNo, size); } diff --git a/db/tests.cpp b/db/tests.cpp index 85804daa499..760535e816a 100644 --- a/db/tests.cpp +++ b/db/tests.cpp @@ -32,7 +32,8 @@ namespace mongo { MemoryMappedFile f; - char *p = (char *) f.map("/tmp/test.dat", 64*1024*1024); + int len = 64*1024*1024; + char *p = (char *) f.map("/tmp/test.dat", len); char *start = p; char *end = p + 64*1024*1024-2; end[1] = 'z'; diff --git a/util/file_allocator.h b/util/file_allocator.h index f043b32ef97..f70a1547bfb 100644 --- a/util/file_allocator.h +++ b/util/file_allocator.h @@ -51,7 +51,7 @@ namespace mongo { } // Returns when file has been allocated. If file exists, size is // updated to match existing file size. - void allocateAsap( const string &name, int size ) { + void allocateAsap( const string &name, int &size ) { { boostlock lk( pendingMutex_ ); int oldSize = prevSize( name ); diff --git a/util/mmap.cpp b/util/mmap.cpp index a68cff77fc2..6b2ee813c33 100644 --- a/util/mmap.cpp +++ b/util/mmap.cpp @@ -58,7 +58,8 @@ namespace mongo { void* MemoryMappedFile::map(const char *filename) { boost::uintmax_t l = boost::filesystem::file_size( filename ); assert( l <= 0x7fffffff ); - return map( filename , (int) l ); + int i = l; + return map( filename , i ); } } // namespace mongo diff --git a/util/mmap.h b/util/mmap.h index 110f041039e..55ae7a7bf37 100644 --- a/util/mmap.h +++ b/util/mmap.h @@ -30,9 +30,10 @@ namespace mongo { // Throws exception if file doesn't exist. void* map( const char *filename ); - /* Creates with length if DNE, otherwise uses existing file length. + /* Creates with length if DNE, otherwise uses existing file length, + passed length. */ - void* map(const char *filename, int length); + void* map(const char *filename, int &length); void flush(bool sync); diff --git a/util/mmap_posix.cpp b/util/mmap_posix.cpp index aacf993e6f1..5cd83a8021d 100644 --- a/util/mmap_posix.cpp +++ b/util/mmap_posix.cpp @@ -50,7 +50,7 @@ namespace mongo { #define O_NOATIME 0 #endif - void* MemoryMappedFile::map(const char *filename, int length) { + void* MemoryMappedFile::map(const char *filename, int &length) { // length may be updated by callee. theFileAllocator().allocateAsap( filename, length ); len = length; diff --git a/util/mmap_win.cpp b/util/mmap_win.cpp index f0d799ad73d..8828263159f 100644 --- a/util/mmap_win.cpp +++ b/util/mmap_win.cpp @@ -49,7 +49,7 @@ namespace mongo { unsigned mapped = 0; - void* MemoryMappedFile::map(const char *_filename, int length) { + void* MemoryMappedFile::map(const char *_filename, int &length) { /* big hack here: Babble uses db names with colons. doesn't seem to work on windows. temporary perhaps. */ char filename[256]; strncpy(filename, _filename, 255);