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

dur forgot to close a view in mmap_win.cpp

This commit is contained in:
Dwight 2010-10-04 16:46:17 -04:00
parent 381fb15249
commit c3fb79d805
6 changed files with 33 additions and 11 deletions

View File

@ -54,8 +54,10 @@ namespace mongo {
}
if( 1 ) {
static int once;
/* temp : not using MongoMMF yet for datafiles, just .ns. more to do... */
RARELY log() << "TEMP TODO _DURABLE : use mongommf for datafiles" << endl;
if( once++ == 0 )
log() << "TEMP TODO _DURABLE : use mongommf for datafiles" << endl;
return p;
}
@ -132,14 +134,19 @@ namespace mongo {
view_write = view_private = view_readonly = 0;
}
MongoMMF::~MongoMMF() {
MongoMMF::~MongoMMF() {
close();
}
/*virtual*/ void MongoMMF::close() {
#if defined(_DEBUG) && defined(_DURABLE)
{
mutex::scoped_lock lk(our_views_mutex);
our_read_views.erase(view_readonly);
}
#endif
view_write = view_private = view_readonly = 0;
view_write = view_private = view_readonly = 0;
MemoryMappedFile::close();
}
}

View File

@ -28,7 +28,8 @@ namespace mongo {
class MongoMMF : private MemoryMappedFile {
public:
MongoMMF();
~MongoMMF();
virtual ~MongoMMF();
virtual void close();
unsigned long long length() const { return MemoryMappedFile::length(); }
bool open(string fname);
bool create(string fname, unsigned long long& len);

View File

@ -512,7 +512,13 @@ namespace QueryTests {
static const char *ns() { return "unittests.querytests.AutoResetIndexCache"; }
static const char *idxNs() { return "unittests.system.indexes"; }
void index() const { ASSERT( !client().findOne( idxNs(), BSON( "name" << NE << "_id_" ) ).isEmpty() ); }
void noIndex() const { ASSERT( client().findOne( idxNs(), BSON( "name" << NE << "_id_" ) ).isEmpty() ); }
void noIndex() const {
BSONObj o = client().findOne( idxNs(), BSON( "name" << NE << "_id_" ) );
if( !o.isEmpty() ) {
cout << o.toString() << endl;
ASSERT( false );
}
}
void checkIndex() {
client().ensureIndex( ns(), BSON( "a" << 1 ) );
index();

View File

@ -91,7 +91,7 @@ namespace mongo {
close();
}
void close();
virtual void close();
// Throws exception if file doesn't exist. (dm may2010: not sure if this is always true?)
void* map(const char *filename);

View File

@ -51,6 +51,7 @@ namespace mongo {
}
void* MemoryMappedFile::testGetCopyOnWriteView() {
assert(false); // todo: not added to views array yet...
assert( maphandle );
void *p = MapViewOfFile(maphandle, FILE_MAP_COPY, /*f ofs hi*/0, /*f ofs lo*/ 0, /*dwNumberOfBytesToMap 0 means to eof*/0);
if ( p == 0 ) {
@ -67,6 +68,9 @@ namespace mongo {
DWORD e = GetLastError();
log() << "FILE_MAP_READ MapViewOfFile failed " << _filename << " " << errnoWithDescription(e) << endl;
}
else {
views.push_back(p);
}
return p;
}
@ -133,6 +137,9 @@ namespace mongo {
DWORD e = GetLastError();
log() << "MapViewOfFile failed " << filename << " " << errnoWithDescription(e) << endl;
}
else {
views.push_back(view);
}
len = length;
#if 0
@ -153,7 +160,6 @@ namespace mongo {
}
#endif
views.push_back(view);
return view;
}

View File

@ -48,9 +48,6 @@ namespace mongo {
#error _MT is not defined
#endif
ss << (sizeof(char *) == 8) ? " 64bit" : " 32bit";
#if defined(_DURABLE)
ss << " _DURABLE";
#endif
return ss.str();
}
#else
@ -58,7 +55,12 @@ namespace mongo {
#endif
#endif
void printSysInfo() { log() << "sys info: " << sysInfo() << endl; }
void printSysInfo() {
log() << "sys info: " << sysInfo() << endl;
#if defined(_DURABLE)
log() << "_DURABLE defined, but durable is not finished" << endl;
#endif
}
//
// 32 bit systems warning