summaryrefslogtreecommitdiff
path: root/src/ActivePeerConnectionCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-01-18 10:11:08 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-01-18 10:11:08 +0000
commitca2567f2a201c738c5aa431b0188f6e51d44f843 (patch)
treea681df878fc6049a13cbf25c7512c3ff4a076e27 /src/ActivePeerConnectionCommand.cc
parent809a28fbae94df53186feb6827af336290850ee4 (diff)
2009-01-18 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added --bt-max-peers option to specify the maximum number of peers per torrent. 0 means unlimited number of peers. * src/ActivePeerConnectionCommand.cc * src/BtRuntime.h * src/DefaultPeerStorage.cc * src/DefaultPeerStorage.h * src/OptionHandlerFactory.cc * src/RequestGroup.cc * src/option_processing.cc * src/prefs.cc * src/prefs.h * src/usage_text.h * test/DefaultPeerStorageTest.cc
Diffstat (limited to 'src/ActivePeerConnectionCommand.cc')
-rw-r--r--src/ActivePeerConnectionCommand.cc16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/ActivePeerConnectionCommand.cc b/src/ActivePeerConnectionCommand.cc
index 10efa710..0a415e13 100644
--- a/src/ActivePeerConnectionCommand.cc
+++ b/src/ActivePeerConnectionCommand.cc
@@ -90,10 +90,18 @@ bool ActivePeerConnectionCommand::execute() {
(!_pieceStorage->downloadFinished() &&
(tstat.getDownloadSpeed() < _thresholdSpeed ||
_btRuntime->lessThanMinPeers()))) {
- unsigned int numConnection = _pieceStorage->downloadFinished() ?
- std::min(_numNewConnection,
- BtRuntime::MAX_PEERS-_btRuntime->getConnections()) :
- _numNewConnection;
+
+ unsigned int numConnection = 0;
+ if(_pieceStorage->downloadFinished()) {
+ if(_btRuntime->getMaxPeers() > _btRuntime->getConnections()) {
+ numConnection =
+ std::min(_numNewConnection,
+ _btRuntime->getMaxPeers()-_btRuntime->getConnections());
+ }
+ } else {
+ numConnection = _numNewConnection;
+ }
+
for(unsigned int numAdd = numConnection;
numAdd > 0 && _peerStorage->isPeerAvailable(); --numAdd) {
PeerHandle peer = _peerStorage->getUnusedPeer();