From a4e7bd7ec4e995852d5413fce4cde3b5ef5e8af1 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 3 Feb 2007 04:17:22 +0000 Subject: [PATCH] 2007-02-03 Tatsuhiro Tsujikawa To lower CPU usage in BitTorrent download when --max-upload-limit command-line option specified: * src/DefaultBtMessageDispatcher.cc (sendMessages): Calculate uploading speed only when current message is uploading data and is not sent yet. * src/DefaultPeerStorage.h (MAX_PEER_LIST_SIZE): 100 -> 60, because 60 is well enough. * src/HttpResponseCommand.cc (handleDefaultEncoding): Added the cast to int32_t to itos. This fixes compile error in Soralis 10. --- ChangeLog | 16 ++++++++++++++++ src/DefaultBtMessageDispatcher.cc | 6 +++--- src/DefaultPeerStorage.h | 2 +- src/HttpResponseCommand.cc | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6265f3598..4e41b684e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2007-02-03 Tatsuhiro Tsujikawa + + To lower CPU usage in BitTorrent download when --max-upload-limit + command-line option specified: + + * src/DefaultBtMessageDispatcher.cc + (sendMessages): Calculate uploading speed only when current message + is uploading data and is not sent yet. + + * src/DefaultPeerStorage.h + (MAX_PEER_LIST_SIZE): 100 -> 60, because 60 is well enough. + + * src/HttpResponseCommand.cc + (handleDefaultEncoding): Added the cast to int32_t to itos. + This fixes compile error in Soralis 10. + 2007-01-30 Tatsuhiro Tsujikawa To fix segfault in Metalink download: diff --git a/src/DefaultBtMessageDispatcher.cc b/src/DefaultBtMessageDispatcher.cc index 91ad32f09..b7e8f3f8f 100644 --- a/src/DefaultBtMessageDispatcher.cc +++ b/src/DefaultBtMessageDispatcher.cc @@ -61,10 +61,10 @@ void DefaultBtMessageDispatcher::sendMessages() { while(messageQueue.size() > 0) { BtMessageHandle msg = messageQueue.front(); messageQueue.pop_front(); - if(maxUploadSpeedLimit > 0) { + if(maxUploadSpeedLimit > 0 && + msg->isUploading() && !msg->isSendingInProgress()) { TransferStat stat = peerStorage->calculateStat(); - if(maxUploadSpeedLimit < stat.getUploadSpeed() && - msg->isUploading() && !msg->isSendingInProgress()) { + if(maxUploadSpeedLimit < stat.getUploadSpeed()) { tempQueue.push_back(msg); continue; } diff --git a/src/DefaultPeerStorage.h b/src/DefaultPeerStorage.h index 756700dd9..21ba102ea 100644 --- a/src/DefaultPeerStorage.h +++ b/src/DefaultPeerStorage.h @@ -41,7 +41,7 @@ #include "Logger.h" #include "BtRuntime.h" -#define MAX_PEER_LIST_SIZE 100 +#define MAX_PEER_LIST_SIZE 60 #define MAX_PEER_ERROR 5 class DefaultPeerStorage : public PeerStorage { diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc index c2cc40700..030d8460e 100644 --- a/src/HttpResponseCommand.cc +++ b/src/HttpResponseCommand.cc @@ -145,7 +145,7 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpHeader& headers) { req->setKeepAlive(false); e->segmentMan->isSplittable = false; e->segmentMan->downloadStarted = true; - e->segmentMan->diskWriter->initAndOpenFile("/tmp/aria2"+Util::itos(getpid())); + e->segmentMan->diskWriter->initAndOpenFile("/tmp/aria2"+Util::itos((int32_t)getpid())); createHttpDownloadCommand(); return true; }