0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

update size in map and allocate asap interfaces

This commit is contained in:
Aaron 2009-04-15 16:11:54 -04:00
parent ab078d2e96
commit f86d33372d
9 changed files with 13 additions and 10 deletions

View File

@ -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");
}

View File

@ -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 ) {

View File

@ -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);
}

View File

@ -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';

View File

@ -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 );

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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);