diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-09-23 10:10:16 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-09-23 10:10:16 +0000 |
| commit | aea9199b40dc690a2307221ca5f19dc40005bdda (patch) | |
| tree | 874d3f36e9f031e7e0a72da8947062679f2bbfea /src/StreamFileAllocationEntry.cc | |
| parent | c56a9bc669bf2c81c49b2dbb84f6630c39bb0a0b (diff) | |
2010-09-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Reset download start time of PeerStat because it is started before
file allocation begins. Without reset, we have incorrect download
time and aria2 wrongly determines that download speed is too low
if --lowest-speed-limit is used.
* src/StreamFileAllocationEntry.cc
Diffstat (limited to 'src/StreamFileAllocationEntry.cc')
| -rw-r--r-- | src/StreamFileAllocationEntry.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/StreamFileAllocationEntry.cc b/src/StreamFileAllocationEntry.cc index 0194bcc0..2dea0068 100644 --- a/src/StreamFileAllocationEntry.cc +++ b/src/StreamFileAllocationEntry.cc @@ -63,6 +63,24 @@ void StreamFileAllocationEntry::prepareForNextAction // RequestGroup::createInitialCommand() getRequestGroup()->getDownloadContext()->resetDownloadStartTime(); if(getNextCommand()) { + // Reset download start time of PeerStat because it is started + // before file allocation begins. + const SharedHandle<DownloadContext>& dctx = + getRequestGroup()->getDownloadContext(); + const std::vector<SharedHandle<FileEntry> >& fileEntries = + dctx->getFileEntries(); + for(std::vector<SharedHandle<FileEntry> >::const_iterator i = + fileEntries.begin(), eoi = fileEntries.end(); i != eoi; ++i) { + const std::deque<SharedHandle<Request> >& reqs = + (*i)->getInFlightRequests(); + for(std::deque<SharedHandle<Request> >::const_iterator j = + reqs.begin(), eoj = reqs.end(); j != eoj; ++j) { + const SharedHandle<PeerStat>& peerStat = (*j)->getPeerStat(); + if(!peerStat.isNull()) { + peerStat->downloadStart(); + } + } + } // give _nextCommand a chance to execute in the next execution loop. getNextCommand()->setStatus(Command::STATUS_ONESHOT_REALTIME); e->setNoWait(true); |
