summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util/mmap_posix.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/util/mmap_posix.cpp b/util/mmap_posix.cpp
index 1ea20fe21f7..c4f486412e8 100644
--- a/util/mmap_posix.cpp
+++ b/util/mmap_posix.cpp
@@ -98,14 +98,28 @@ namespace mongo {
return view;
}
+
+ void* MemoryMappedFile::createReadOnlyMap() {
+ void * x = mmap( /*start*/0 , len , PROT_READ , MAP_SHARED , fd , 0 );
+ if( x == MAP_FAILED ) {
+ if ( errno == ENOMEM ) {
+ if( sizeof(void*) == 4 )
+ error() << "mmap ro failed with out of memory. You are using a 32-bit build and probably need to upgrade to 64" << endl;
+ else
+ error() << "mmap ro failed with out of memory. (64 bit build)" << endl;
+ }
+ return 0;
+ }
+ return x;
+ }
- void* MemoryMappedFile::testGetCopyOnWriteView(){
+ void* MemoryMappedFile::testGetCopyOnWriteView() {
void * x = mmap( NULL , len , PROT_READ | PROT_WRITE , MAP_PRIVATE , fd , 0 );
- assert( x );
+ assert( x != MAP_FAILED );
return x;
}
- void MemoryMappedFile::testCloseCopyOnWriteView(void * x ){
+ void MemoryMappedFile::testCloseCopyOnWriteView(void * x ) {
munmap(x,len);
}