From a4e7bd7ec4e995852d5413fce4cde3b5ef5e8af1 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 3 Feb 2007 04:17:22 +0000 Subject: 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. --- src/DefaultBtMessageDispatcher.cc | 6 +++--- src/DefaultPeerStorage.h | 2 +- src/HttpResponseCommand.cc | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/DefaultBtMessageDispatcher.cc b/src/DefaultBtMessageDispatcher.cc index 91ad32f0..b7e8f3f8 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 756700dd..21ba102e 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 c2cc4070..030d8460 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; } -- cgit