diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-03-26 17:12:52 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-03-26 17:20:27 +0900 |
| commit | d64089632e82a2548752c7a6baaa68365a795a74 (patch) | |
| tree | 57fc7b85a8c1290975d58fa4761b04a7695bf7e3 /src/StreamFileAllocationEntry.cc | |
| parent | c81b1321122e8509b55c94c0cbca0d8d6d319f0c (diff) | |
| parent | a7cd943a06b1a5ff4515b57060b84037f8d01f9f (diff) | |
Merge branch 'master' into random-webseeding
Diffstat (limited to 'src/StreamFileAllocationEntry.cc')
| -rw-r--r-- | src/StreamFileAllocationEntry.cc | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/StreamFileAllocationEntry.cc b/src/StreamFileAllocationEntry.cc index dfe1f679..e02bbc48 100644 --- a/src/StreamFileAllocationEntry.cc +++ b/src/StreamFileAllocationEntry.cc @@ -49,35 +49,40 @@ namespace aria2 { -StreamFileAllocationEntry::StreamFileAllocationEntry -(RequestGroup* requestGroup, std::unique_ptr<Command> nextCommand): - FileAllocationEntry(requestGroup, std::move(nextCommand)) -{} +StreamFileAllocationEntry::StreamFileAllocationEntry( + RequestGroup* requestGroup, std::unique_ptr<Command> nextCommand) + : FileAllocationEntry(requestGroup, std::move(nextCommand)) +{ +} StreamFileAllocationEntry::~StreamFileAllocationEntry() {} -void StreamFileAllocationEntry::prepareForNextAction -(std::vector<std::unique_ptr<Command>>& commands, - DownloadEngine* e) +void StreamFileAllocationEntry::prepareForNextAction( + std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e) { + auto& option = getRequestGroup()->getOption(); + // For DownloadContext::resetDownloadStartTime(), see also // RequestGroup::createInitialCommand() getRequestGroup()->getDownloadContext()->resetDownloadStartTime(); - if(getRequestGroup()->getOption()->getAsBool(PREF_ENABLE_MMAP)) { + if (option->getAsBool(PREF_ENABLE_MMAP) && + option->get(PREF_FILE_ALLOCATION) != V_NONE && + getRequestGroup()->getPieceStorage()->getDiskAdaptor()->size() <= + option->getAsLLInt(PREF_MAX_MMAP_LIMIT)) { getRequestGroup()->getPieceStorage()->getDiskAdaptor()->enableMmap(); } - if(getNextCommand()) { + if (getNextCommand()) { // Reset download start time of PeerStat because it is started // before file allocation begins. const std::shared_ptr<DownloadContext>& dctx = - getRequestGroup()->getDownloadContext(); - const std::vector<std::shared_ptr<FileEntry> >& fileEntries = - dctx->getFileEntries(); - for(auto & f : fileEntries) { + getRequestGroup()->getDownloadContext(); + const std::vector<std::shared_ptr<FileEntry>>& fileEntries = + dctx->getFileEntries(); + for (auto& f : fileEntries) { const auto& reqs = f->getInFlightRequests(); - for(auto & req : reqs) { + for (auto& req : reqs) { const std::shared_ptr<PeerStat>& peerStat = req->getPeerStat(); - if(peerStat) { + if (peerStat) { peerStat->downloadStart(); } } @@ -88,7 +93,8 @@ void StreamFileAllocationEntry::prepareForNextAction commands.push_back(popNextCommand()); // try remaining uris getRequestGroup()->createNextCommandWithAdj(commands, e, -1); - } else { + } + else { getRequestGroup()->createNextCommandWithAdj(commands, e, 0); } } |
