summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-02-03 04:17:22 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-02-03 04:17:22 +0000
commita4e7bd7ec4e995852d5413fce4cde3b5ef5e8af1 (patch)
treee30f8ba9a2c7c0540353f78200faf8be978b9fb7 /src
parent77a05c00b1410687a3045ffe693aaa0496361fc8 (diff)
2007-02-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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.
Diffstat (limited to 'src')
-rw-r--r--src/DefaultBtMessageDispatcher.cc6
-rw-r--r--src/DefaultPeerStorage.h2
-rw-r--r--src/HttpResponseCommand.cc2
3 files changed, 5 insertions, 5 deletions
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;
}