From aea9199b40dc690a2307221ca5f19dc40005bdda Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 23 Sep 2010 10:10:16 +0000 Subject: 2010-09-23 Tatsuhiro Tsujikawa 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 --- src/StreamFileAllocationEntry.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/StreamFileAllocationEntry.cc') 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& dctx = + getRequestGroup()->getDownloadContext(); + const std::vector >& fileEntries = + dctx->getFileEntries(); + for(std::vector >::const_iterator i = + fileEntries.begin(), eoi = fileEntries.end(); i != eoi; ++i) { + const std::deque >& reqs = + (*i)->getInFlightRequests(); + for(std::deque >::const_iterator j = + reqs.begin(), eoj = reqs.end(); j != eoj; ++j) { + const SharedHandle& 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); -- cgit