summaryrefslogtreecommitdiff
path: root/src/PeerReceiveHandshakeCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-05-07 08:40:45 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-05-07 08:40:45 +0000
commit40d5c1e763206bfe1d2e4aa9508ec8b3f4e66641 (patch)
treefeefd0c0a33f9c9a781c51d392f1727488081966 /src/PeerReceiveHandshakeCommand.cc
parent22ab845df55f950a82adab8934a516005747a868 (diff)
2009-05-07 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Don't retrieve PREF_MAX_DOWNLOAD_LIMIT and PREF_MAX_UPLOAD_LIMIT from option directly. Instead, get them from RequestGroup. * src/ActivePeerConnectionCommand.cc * src/ActivePeerConnectionCommand.h * src/PeerReceiveHandshakeCommand.cc * src/RequestGroup.h
Diffstat (limited to 'src/PeerReceiveHandshakeCommand.cc')
-rw-r--r--src/PeerReceiveHandshakeCommand.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/PeerReceiveHandshakeCommand.cc b/src/PeerReceiveHandshakeCommand.cc
index ad89c13f..e5bf415a 100644
--- a/src/PeerReceiveHandshakeCommand.cc
+++ b/src/PeerReceiveHandshakeCommand.cc
@@ -73,10 +73,6 @@ PeerReceiveHandshakeCommand::PeerReceiveHandshakeCommand
if(_peerConnection.isNull()) {
_peerConnection.reset(new PeerConnection(cuid, socket, e->option));
}
- unsigned int maxDownloadSpeed = e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT);
- if(maxDownloadSpeed > 0) {
- _thresholdSpeed = std::min(maxDownloadSpeed, _thresholdSpeed);
- }
}
PeerReceiveHandshakeCommand::~PeerReceiveHandshakeCommand() {}
@@ -111,8 +107,15 @@ bool PeerReceiveHandshakeCommand::executeInternal()
(StringFormat("Unknown info hash %s", infoHash.c_str()).str());
}
TransferStat tstat = btContext->getOwnerRequestGroup()->calculateStat();
+ const unsigned int maxDownloadLimit =
+ btContext->getOwnerRequestGroup()->getMaxDownloadSpeedLimit();
+ unsigned int thresholdSpeed = _thresholdSpeed;
+ if(maxDownloadLimit > 0) {
+ thresholdSpeed = std::min(maxDownloadLimit, _thresholdSpeed);
+ }
+
if((!pieceStorage->downloadFinished() &&
- tstat.getDownloadSpeed() < _thresholdSpeed) ||
+ tstat.getDownloadSpeed() < thresholdSpeed) ||
btRuntime->lessThanMaxPeers()) {
if(peerStorage->addPeer(peer)) {