mirror of
https://github.com/aria2/aria2.git
synced 2025-01-01 15:44:55 +00:00
Fixed bug that mmap won't work if MultiDiskAdaptor is used
This commit is contained in:
parent
71620854c7
commit
5367c34de3
@ -90,6 +90,8 @@ public:
|
||||
|
||||
virtual bool isReadOnlyEnabled() const { return false; }
|
||||
|
||||
// Enables mmap feature. Some derived classes may require that files
|
||||
// have been opened before this method call.
|
||||
virtual void enableMmap() {}
|
||||
|
||||
// Assumed each file length is stored in fileEntries or DiskAdaptor knows it.
|
||||
|
@ -119,8 +119,7 @@ bool DiskWriterEntry::operator<(const DiskWriterEntry& entry) const
|
||||
MultiDiskAdaptor::MultiDiskAdaptor()
|
||||
: pieceLength_(0),
|
||||
maxOpenFiles_(DEFAULT_MAX_OPEN_FILES),
|
||||
readOnly_(false),
|
||||
enableMmap_(false)
|
||||
readOnly_(false)
|
||||
{}
|
||||
|
||||
MultiDiskAdaptor::~MultiDiskAdaptor() {}
|
||||
@ -230,9 +229,8 @@ void MultiDiskAdaptor::resetDiskWriterEntries()
|
||||
if(readOnly_) {
|
||||
(*i)->getDiskWriter()->enableReadOnly();
|
||||
}
|
||||
if(enableMmap_) {
|
||||
(*i)->getDiskWriter()->enableMmap();
|
||||
}
|
||||
// TODO mmap is not enabled at this moment. Call enableMmap()
|
||||
// after this function call.
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -456,7 +454,14 @@ void MultiDiskAdaptor::disableReadOnly()
|
||||
|
||||
void MultiDiskAdaptor::enableMmap()
|
||||
{
|
||||
enableMmap_ = true;
|
||||
for(std::vector<SharedHandle<DiskWriterEntry> >::const_iterator i =
|
||||
diskWriterEntries_.begin(), eoi = diskWriterEntries_.end();
|
||||
i != eoi; ++i) {
|
||||
const SharedHandle<DiskWriter>& dw = (*i)->getDiskWriter();
|
||||
if(dw) {
|
||||
dw->enableMmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MultiDiskAdaptor::cutTrailingGarbage()
|
||||
|
@ -110,7 +110,6 @@ private:
|
||||
int maxOpenFiles_;
|
||||
|
||||
bool readOnly_;
|
||||
bool enableMmap_;
|
||||
|
||||
void resetDiskWriterEntries();
|
||||
|
||||
@ -148,6 +147,8 @@ public:
|
||||
|
||||
virtual bool isReadOnlyEnabled() const { return readOnly_; }
|
||||
|
||||
// Enables mmap feature. This method must be called after files are
|
||||
// opened.
|
||||
virtual void enableMmap();
|
||||
|
||||
void setPieceLength(int32_t pieceLength)
|
||||
|
Loading…
Reference in New Issue
Block a user