mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 01:21:03 +01:00
be sure we are flushing the right view
This commit is contained in:
parent
15dcbf6866
commit
9ccbf56791
@ -27,6 +27,9 @@ namespace mongo {
|
||||
not this.
|
||||
*/
|
||||
class MongoMMF : private MemoryMappedFile {
|
||||
protected:
|
||||
virtual void* viewForFlushing() { return _view_write; }
|
||||
|
||||
public:
|
||||
MongoMMF();
|
||||
virtual ~MongoMMF();
|
||||
|
@ -135,6 +135,13 @@ namespace mongo {
|
||||
};
|
||||
|
||||
class MemoryMappedFile : public MongoFile {
|
||||
protected:
|
||||
virtual void* viewForFlushing() {
|
||||
if( views.size() == 0 )
|
||||
return 0;
|
||||
assert( views.size() == 1 );
|
||||
return views[0];
|
||||
}
|
||||
public:
|
||||
MemoryMappedFile();
|
||||
|
||||
@ -187,7 +194,7 @@ namespace mongo {
|
||||
HANDLE maphandle;
|
||||
vector<void *> views;
|
||||
unsigned long long len;
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
boost::shared_ptr<mutex> _flushMutex;
|
||||
void clearWritableBits(void *privateView);
|
||||
|
@ -155,7 +155,7 @@ namespace mongo {
|
||||
void MemoryMappedFile::flush(bool sync) {
|
||||
if ( views.empty() || fd == 0 )
|
||||
return;
|
||||
if ( msync(views[0], len, sync ? MS_SYNC : MS_ASYNC) )
|
||||
if ( msync(viewForFlushing(), len, sync ? MS_SYNC : MS_ASYNC) )
|
||||
problem() << "msync " << errnoWithDescription() << endl;
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ namespace mongo {
|
||||
};
|
||||
|
||||
MemoryMappedFile::Flushable * MemoryMappedFile::prepareFlush() {
|
||||
return new PosixFlushable( views.empty() ? 0 : views[0] , fd , len );
|
||||
return new PosixFlushable( viewForFlushing() , fd , len );
|
||||
}
|
||||
|
||||
void MemoryMappedFile::_lock() {
|
||||
|
@ -183,13 +183,13 @@ namespace mongo {
|
||||
void MemoryMappedFile::flush(bool sync) {
|
||||
uassert(13056, "Async flushing not supported on windows", sync);
|
||||
if( !views.empty() ) {
|
||||
WindowsFlushable f( views[0] , fd , filename() , _flushMutex);
|
||||
WindowsFlushable f( viewForFlushing() , fd , filename() , _flushMutex);
|
||||
f.flush();
|
||||
}
|
||||
}
|
||||
|
||||
MemoryMappedFile::Flushable * MemoryMappedFile::prepareFlush() {
|
||||
return new WindowsFlushable( views.empty() ? 0 : views[0] , fd , filename() , _flushMutex );
|
||||
return new WindowsFlushable( viewForFlushing() , fd , filename() , _flushMutex );
|
||||
}
|
||||
void MemoryMappedFile::_lock() {}
|
||||
void MemoryMappedFile::_unlock() {}
|
||||
|
Loading…
Reference in New Issue
Block a user