Bläddra i källkod

2008-09-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Fixed the bug that aria2 downloads faster than 
max-download-limit when
	downloading file using both HTTP(or FTP) and BitTorrent, because 
aria2
	evaluates speed separatly(HTTP and BiTorrent) against 
max-download-limit
	, instead of sum of them.
	* src/ActivePeerConnectionCommand.cc
	* src/DefaultBtInteractive.cc
	* src/DownloadCommand.cc
	* src/PeerInteractionCommand.cc
	* src/PeerReceiveHandshakeCommand.cc
Tatsuhiro Tsujikawa 17 år sedan
förälder
incheckning
db5944b29b

+ 12 - 0
ChangeLog

@@ -1,3 +1,15 @@
+2008-09-28  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Fixed the bug that aria2 downloads faster than max-download-limit when
+	downloading file using both HTTP(or FTP) and BitTorrent, because aria2
+	evaluates speed separatly(HTTP and BiTorrent) against max-download-limit
+	, instead of sum of them.
+	* src/ActivePeerConnectionCommand.cc
+	* src/DefaultBtInteractive.cc
+	* src/DownloadCommand.cc
+	* src/PeerInteractionCommand.cc
+	* src/PeerReceiveHandshakeCommand.cc
+
 2008-09-27  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 2008-09-27  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 
 	Fixed the bug that HTTPS download fails.
 	Fixed the bug that HTTPS download fails.

+ 2 - 1
src/ActivePeerConnectionCommand.cc

@@ -48,6 +48,7 @@
 #include "BtConstants.h"
 #include "BtConstants.h"
 #include "SocketCore.h"
 #include "SocketCore.h"
 #include "BtAnnounce.h"
 #include "BtAnnounce.h"
+#include "RequestGroup.h"
 
 
 namespace aria2 {
 namespace aria2 {
 
 
@@ -79,7 +80,7 @@ bool ActivePeerConnectionCommand::execute() {
   }
   }
   if(checkPoint.elapsed(interval)) {
   if(checkPoint.elapsed(interval)) {
     checkPoint.reset();
     checkPoint.reset();
-    TransferStat tstat = peerStorage->calculateStat();
+    TransferStat tstat = _requestGroup->calculateStat();
     if(// for seeder state
     if(// for seeder state
        (pieceStorage->downloadFinished() && btRuntime->lessThanMaxPeers() &&
        (pieceStorage->downloadFinished() && btRuntime->lessThanMaxPeers() &&
 	(_maxUploadSpeedLimit == 0 ||
 	(_maxUploadSpeedLimit == 0 ||

+ 2 - 1
src/DefaultBtInteractive.cc

@@ -65,6 +65,7 @@
 #include "Logger.h"
 #include "Logger.h"
 #include "LogFactory.h"
 #include "LogFactory.h"
 #include "StringFormat.h"
 #include "StringFormat.h"
+#include "RequestGroup.h"
 #include <cstring>
 #include <cstring>
 
 
 namespace aria2 {
 namespace aria2 {
@@ -234,7 +235,7 @@ size_t DefaultBtInteractive::receiveMessages() {
   size_t msgcount = 0;
   size_t msgcount = 0;
   for(int i = 0; i < 50; i++) {
   for(int i = 0; i < 50; i++) {
     if(maxDownloadSpeedLimit > 0) {
     if(maxDownloadSpeedLimit > 0) {
-      TransferStat stat = peerStorage->calculateStat();
+      TransferStat stat = btContext->getOwnerRequestGroup()->calculateStat();
       if(maxDownloadSpeedLimit < stat.downloadSpeed) {
       if(maxDownloadSpeedLimit < stat.downloadSpeed) {
 	break;
 	break;
       }
       }

+ 2 - 1
src/DownloadCommand.cc

@@ -101,7 +101,8 @@ DownloadCommand::~DownloadCommand() {
 
 
 bool DownloadCommand::executeInternal() {
 bool DownloadCommand::executeInternal() {
   if(maxDownloadSpeedLimit > 0 &&
   if(maxDownloadSpeedLimit > 0 &&
-     maxDownloadSpeedLimit < _requestGroup->getSegmentMan()->calculateDownloadSpeed()) {
+     maxDownloadSpeedLimit <
+     _requestGroup->calculateStat().getDownloadSpeed()) {
     e->commands.push_back(this);
     e->commands.push_back(this);
     disableReadCheckSocket();
     disableReadCheckSocket();
     return false;
     return false;

+ 1 - 1
src/PeerInteractionCommand.cc

@@ -239,7 +239,7 @@ bool PeerInteractionCommand::executeInternal() {
       //       }
       //       }
 
 
       if(maxDownloadSpeedLimit > 0) {
       if(maxDownloadSpeedLimit > 0) {
-	TransferStat stat = peerStorage->calculateStat();
+	TransferStat stat = _requestGroup->calculateStat();
 	if(maxDownloadSpeedLimit < stat.downloadSpeed) {
 	if(maxDownloadSpeedLimit < stat.downloadSpeed) {
 	  disableReadCheckSocket();
 	  disableReadCheckSocket();
 	  setNoCheck(true);
 	  setNoCheck(true);

+ 2 - 1
src/PeerReceiveHandshakeCommand.cc

@@ -53,6 +53,7 @@
 #include "Option.h"
 #include "Option.h"
 #include "RequestGroupMan.h"
 #include "RequestGroupMan.h"
 #include "StringFormat.h"
 #include "StringFormat.h"
+#include "RequestGroup.h"
 
 
 namespace aria2 {
 namespace aria2 {
 
 
@@ -97,7 +98,7 @@ bool PeerReceiveHandshakeCommand::executeInternal()
       throw DlAbortEx
       throw DlAbortEx
 	(StringFormat("Unknown info hash %s", infoHash.c_str()).str());
 	(StringFormat("Unknown info hash %s", infoHash.c_str()).str());
     }
     }
-    TransferStat tstat = PEER_STORAGE(btContext)->calculateStat();
+    TransferStat tstat = btContext->getOwnerRequestGroup()->calculateStat();
     if((!PIECE_STORAGE(btContext)->downloadFinished() &&
     if((!PIECE_STORAGE(btContext)->downloadFinished() &&
        tstat.getDownloadSpeed() < _thresholdSpeed) ||
        tstat.getDownloadSpeed() < _thresholdSpeed) ||
        BT_RUNTIME(btContext)->lessThanMaxPeers()) {
        BT_RUNTIME(btContext)->lessThanMaxPeers()) {