mirror of
https://github.com/aria2/aria2.git
synced 2025-01-08 11:01:38 +00:00
Fix bug that numOpenFile_ is not reduced when MultiDiskAdaptor is deleted
This bug caused assertion error in RequestGroupMan::ensureMaxOpenFileLimit
This commit is contained in:
parent
3802c8dc2c
commit
8216bdba79
@ -124,7 +124,10 @@ MultiDiskAdaptor::MultiDiskAdaptor()
|
||||
readOnly_{false}
|
||||
{}
|
||||
|
||||
MultiDiskAdaptor::~MultiDiskAdaptor() {}
|
||||
MultiDiskAdaptor::~MultiDiskAdaptor()
|
||||
{
|
||||
closeFile();
|
||||
}
|
||||
|
||||
namespace {
|
||||
std::unique_ptr<DiskWriterEntry> createDiskWriterEntry
|
||||
@ -267,10 +270,15 @@ void MultiDiskAdaptor::openExistingFile()
|
||||
|
||||
void MultiDiskAdaptor::closeFile()
|
||||
{
|
||||
size_t n = 0;
|
||||
openedDiskWriterEntries_.clear();
|
||||
for(auto& dwent : diskWriterEntries_) {
|
||||
dwent->closeFile();
|
||||
if(dwent->isOpen()) {
|
||||
++n;
|
||||
dwent->closeFile();
|
||||
}
|
||||
}
|
||||
getRequestGroupMan()->reduceNumOfOpenedFile(n);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -985,4 +985,10 @@ void RequestGroupMan::ensureMaxOpenFileLimit(size_t numNewFile)
|
||||
numOpenFile_ += numNewFile - numClose;
|
||||
}
|
||||
|
||||
void RequestGroupMan::reduceNumOfOpenedFile(size_t numCloseFile)
|
||||
{
|
||||
assert(numOpenFile_ >= numCloseFile);
|
||||
numOpenFile_ -= numCloseFile;
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
@ -357,6 +357,8 @@ public:
|
||||
// Currently the only download using MultiDiskAdaptor is affected by
|
||||
// the global limit.
|
||||
void ensureMaxOpenFileLimit(size_t numNewFile);
|
||||
// Reduces the number of open files managed by this object.
|
||||
void reduceNumOfOpenedFile(size_t numCloseFile);
|
||||
};
|
||||
|
||||
} // namespace aria2
|
||||
|
Loading…
Reference in New Issue
Block a user