mirror of
https://github.com/aria2/aria2.git
synced 2025-01-01 07:36:24 +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; }
|
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() {}
|
virtual void enableMmap() {}
|
||||||
|
|
||||||
// Assumed each file length is stored in fileEntries or DiskAdaptor knows it.
|
// 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()
|
MultiDiskAdaptor::MultiDiskAdaptor()
|
||||||
: pieceLength_(0),
|
: pieceLength_(0),
|
||||||
maxOpenFiles_(DEFAULT_MAX_OPEN_FILES),
|
maxOpenFiles_(DEFAULT_MAX_OPEN_FILES),
|
||||||
readOnly_(false),
|
readOnly_(false)
|
||||||
enableMmap_(false)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
MultiDiskAdaptor::~MultiDiskAdaptor() {}
|
MultiDiskAdaptor::~MultiDiskAdaptor() {}
|
||||||
@ -230,9 +229,8 @@ void MultiDiskAdaptor::resetDiskWriterEntries()
|
|||||||
if(readOnly_) {
|
if(readOnly_) {
|
||||||
(*i)->getDiskWriter()->enableReadOnly();
|
(*i)->getDiskWriter()->enableReadOnly();
|
||||||
}
|
}
|
||||||
if(enableMmap_) {
|
// TODO mmap is not enabled at this moment. Call enableMmap()
|
||||||
(*i)->getDiskWriter()->enableMmap();
|
// after this function call.
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -456,7 +454,14 @@ void MultiDiskAdaptor::disableReadOnly()
|
|||||||
|
|
||||||
void MultiDiskAdaptor::enableMmap()
|
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()
|
void MultiDiskAdaptor::cutTrailingGarbage()
|
||||||
|
@ -110,7 +110,6 @@ private:
|
|||||||
int maxOpenFiles_;
|
int maxOpenFiles_;
|
||||||
|
|
||||||
bool readOnly_;
|
bool readOnly_;
|
||||||
bool enableMmap_;
|
|
||||||
|
|
||||||
void resetDiskWriterEntries();
|
void resetDiskWriterEntries();
|
||||||
|
|
||||||
@ -148,6 +147,8 @@ public:
|
|||||||
|
|
||||||
virtual bool isReadOnlyEnabled() const { return readOnly_; }
|
virtual bool isReadOnlyEnabled() const { return readOnly_; }
|
||||||
|
|
||||||
|
// Enables mmap feature. This method must be called after files are
|
||||||
|
// opened.
|
||||||
virtual void enableMmap();
|
virtual void enableMmap();
|
||||||
|
|
||||||
void setPieceLength(int32_t pieceLength)
|
void setPieceLength(int32_t pieceLength)
|
||||||
|
Loading…
Reference in New Issue
Block a user