summaryrefslogtreecommitdiff
path: root/src/PeerInteractionCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-09-21 13:49:06 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-09-21 13:49:06 +0000
commit8b8325cafcfecc8c32a4f49a48ee7cfcc68d450a (patch)
treeed9621c75ee6d0c95f6dcc3064adc14322e179a9 /src/PeerInteractionCommand.cc
parent65e0ffe6caa5f3ad9b4ccf49045f9e7ed144ee07 (diff)
* src/PeerChokeCommand.cc
(optUnchokingPeer): Updated according to the changes in Peer. (ResetDelta): Removed. (UploadFaster): Updated according to the changes in Peer. (DownloadFaster): Updated according to the changes in Peer. (execute): I clarify the meaning of "upload" and "download" here. "upload" means the transfer from localhost to remote host. "download" means the transfer from remote host to localhost. Based on this rule, I swapped orderByUploadRate and orderByDownloadRate. * src/PeerInteractionCommand.cc (PeerInteraction): Removed peerInteraction->setUploadLImit(). (executeInternal): Removed the argument of peerInteraction->sendMessages(). (receiveMessages): Rewritten download speed limit. (sendKeepAlive): Removed peerInteraction->sendMessages(). * src/HttpResponseCommand.cc (handleDefaultEncoding): If file size is unknown in torrent request, do not call segmentMan->initBitfield() here. Disabled persistent connection feature in torrent request. * src/UrlRequestInfo.h (UrlRequestInfo): Removed const qualifier from option. * src/TorrentMan.h (TransferStat): New class. (deltaDownloadLength): Removed. (deltaUploadLength): Removed. (addDeltaDownloadLength): Removed. (getDeltaDownloadLength): Removed. (resetDeltaDownloadLength): Removed. (addDeltaUploadLength): Removed. (getDeltaUploadLength): Removed. (resetDeltaUploadLength): Removed. (addActivePeer): Added peer->activate(). (deleteActivePeer): Added peer->deactivate(). (calculateStat): New function. * src/TorrentMan.cc (TorrentMan): Removed deltaDownloadLength and deltaUploadLength. (calculateStat): New function. * src/PeerInteraction.h (uploadLimit): Removed. (option): New variable. (setUploadLimit): Removed. (getUploadSpeed): Removed. (sendMessages): Removed the argument "currentUploadSpeed". * src/PeerInteraction.cc (prefs.h): Included. (PeerInteraction): Removed uploadLimit. Added option. (sendMessages): Rewritten upload speed limit. (sendHandshake): Removed the argument from sendMessages(). (sendBitfield): Removed the argument from sendMessages(). * src/PeerAbstractCommand.cc (execute): Commented out the portion of upload limit. (onAbort): Removed peer->resetStatus(). * src/TorrentRequestInfo.cc (timeoutSpecified): Declared extern. (execute): Set timeout to 180 if timeout is not specified by. command-line. * src/PieceMessage.cc (receivedAction): Added peer->updateDownloadLength(). Removed peer->addPeerUpload(). Removed torrentMan->addDeltaDownloadLength(). (send): Added peer->updateUploadLength(). Removed peer->addPeerDownload(). Removed torrentMan->addDeltaUploadLength(). * src/main.cc (timeoutSpecified): New variable. (main): Set timeoutSpecified to false. If the command-line option "--upload-limit" is specified, then timeoutSpecified is set to true. This option will remain in the next release, but be deprecated in the future release. * src/TorrentRequestInfo.h (TorrentRequestInfo): Removed const qualifier from op. * src/PeerStat.h (uploadSpeed): New variable. (PeerStat): Added default value to cuid. (calculateUploadSpeed): New function. (updateUploadLength): New function. (getMaxUploadSpeed): New function. (getAvgUploadSpeed): New function. (reset): Added uploadSpeed. Set status to IDLE. * src/TorrentDownloadEngine.h (cp): Declared as Time. (sessionDownloadLengthArray): Removed. (sessionUploadLengthArray): Removed. (currentCp): Removed. (lastCalcStat): New variable (lastElapsed): Removed. (sessionDownloadLength): Removed. (calculateStat): New function. * src/TorrentDownloadEngine.cc (initStatistics): Removed lastElapsed, cp[], sessionDownloadLengthArray[], sessionUploadLengthArray[], currentCp, sessionDownloadLength. Added cp.reset() and lastCalcStat.reset(). (calculateSpeed): Changed the name of the argument. (calculateStatistics): Rewritten. (calculateStat): New function. * src/Peer.h (PeerStat.h): Included. (peerUpload): Removed. (peerDownload): Removed. (peerStat): New variable. (sessionUploadLength): New variable. (sessionDownloadLength): New variable. (deltaUpload): Removed. (deltaDownload): Removed. (resetStatus): Made private. (Peer): Added sessionUploadLength, sessionDownloadLength. Removed peerUpload, peerDownload. (updateUploadLength): New function. (addDeltaUpload): Removed. (updateDownloadLength): New function. (resetDeltaUpload): Removed. (getDeltaUpload): Removed. (addDeltaDownload): Removed. (calculateUploadSpeed): New function. (resetDeltaDownload): Removed. (getDeltaDownload): Removed. (calculateDownloadSpeed): New function. (getSessionUploadLength): New function. (getSessionDownloadLength): New function. (activate): New function. (deactivate): New function. (addPeerUpload): Removed. (setPeerUpload): Removed. (getPeerUpload): Removed. (addPeerDownload): Removed. (setPeerDownload): Removed. (getPeerDownload): Removed. * src/Peer.cc (resetStatus): Removed resetDeltaUpload() and resetDeltaDownload(). * src/MetalinkRequestInfo.h (MetalinkRequestInfo): Removed const qualifier from op. * src/RequestInfo.h (op): Removed const qualifier. (RequestInfo): Removed const qualifier from op.
Diffstat (limited to 'src/PeerInteractionCommand.cc')
-rw-r--r--src/PeerInteractionCommand.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/PeerInteractionCommand.cc b/src/PeerInteractionCommand.cc
index a6b4ab02..2adee58c 100644
--- a/src/PeerInteractionCommand.cc
+++ b/src/PeerInteractionCommand.cc
@@ -46,7 +46,6 @@ PeerInteractionCommand::PeerInteractionCommand(int cuid,
}
peerInteraction = new PeerInteraction(cuid, peer, socket, e->option,
e->torrentMan);
- peerInteraction->setUploadLimit(e->option->getAsInt(PREF_UPLOAD_LIMIT));
setUploadLimit(e->option->getAsInt(PREF_UPLOAD_LIMIT));
chokeUnchokeCount = 0;
haveCount = 0;
@@ -78,7 +77,7 @@ bool PeerInteractionCommand::executeInternal() {
break;
case INITIATOR_WAIT_HANDSHAKE: {
if(peerInteraction->countMessageInQueue() > 0) {
- peerInteraction->sendMessages(e->getUploadSpeed());
+ peerInteraction->sendMessages();
if(peerInteraction->countMessageInQueue() > 0) {
break;
}
@@ -129,7 +128,7 @@ bool PeerInteractionCommand::executeInternal() {
peerInteraction->addRequests();
- peerInteraction->sendMessages(e->getUploadSpeed());
+ peerInteraction->sendMessages();
break;
}
if(peerInteraction->countMessageInQueue() > 0) {
@@ -192,10 +191,13 @@ void PeerInteractionCommand::decideChoking() {
void PeerInteractionCommand::receiveMessages() {
for(int i = 0; i < 50; i++) {
int maxSpeedLimit = e->option->getAsInt(PREF_MAX_SPEED_LIMIT);
- if(maxSpeedLimit > 0 && maxSpeedLimit < e->getDownloadSpeed()) {
- disableReadCheckSocket();
- setNoCheck(true);
- break;
+ if(maxSpeedLimit > 0) {
+ TransferStat stat = e->torrentMan->calculateStat();
+ if(maxSpeedLimit < stat.downloadSpeed) {
+ disableReadCheckSocket();
+ setNoCheck(true);
+ break;
+ }
}
PeerMessageHandle message = peerInteraction->receiveMessage();
@@ -256,7 +258,7 @@ void PeerInteractionCommand::sendKeepAlive() {
if(peerInteraction->countMessageInQueue() == 0) {
peerInteraction->addMessage(peerInteraction->getPeerMessageFactory()->
createKeepAliveMessage());
- peerInteraction->sendMessages(e->getUploadSpeed());
+ peerInteraction->sendMessages();
}
keepAliveCheckPoint.reset();
}