Explorar o código

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
Tatsuhiro Tsujikawa %!s(int64=15) %!d(string=hai) anos
pai
achega
aea9199b40
Modificáronse 2 ficheiros con 26 adicións e 0 borrados
  1. 8 0
      ChangeLog
  2. 18 0
      src/StreamFileAllocationEntry.cc

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+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
+
 2010-09-19  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Added keys parameter to aria2.tellStatus, aria2.tellActive,

+ 18 - 0
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);