diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-05-07 08:40:45 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-05-07 08:40:45 +0000 |
| commit | 40d5c1e763206bfe1d2e4aa9508ec8b3f4e66641 (patch) | |
| tree | feefd0c0a33f9c9a781c51d392f1727488081966 /src/ActivePeerConnectionCommand.cc | |
| parent | 22ab845df55f950a82adab8934a516005747a868 (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/ActivePeerConnectionCommand.cc')
| -rw-r--r-- | src/ActivePeerConnectionCommand.cc | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/ActivePeerConnectionCommand.cc b/src/ActivePeerConnectionCommand.cc index 79405c87..828488e0 100644 --- a/src/ActivePeerConnectionCommand.cc +++ b/src/ActivePeerConnectionCommand.cc @@ -64,13 +64,8 @@ ActivePeerConnectionCommand::ActivePeerConnectionCommand interval(interval), e(e), _thresholdSpeed(e->option->getAsInt(PREF_BT_REQUEST_PEER_SPEED_LIMIT)), - _maxUploadSpeedLimit(e->option->getAsInt(PREF_MAX_UPLOAD_LIMIT)), _numNewConnection(5) { - unsigned int maxDownloadSpeed = e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT); - if(maxDownloadSpeed > 0) { - _thresholdSpeed = std::min(maxDownloadSpeed, _thresholdSpeed); - } _requestGroup->increaseNumCommand(); } @@ -86,13 +81,19 @@ bool ActivePeerConnectionCommand::execute() { if(checkPoint.elapsed(interval)) { checkPoint.reset(); TransferStat tstat = _requestGroup->calculateStat(); + const unsigned int maxDownloadLimit = + _requestGroup->getMaxDownloadSpeedLimit(); + const unsigned int maxUploadLimit = _requestGroup->getMaxUploadSpeedLimit(); + unsigned int thresholdSpeed = _thresholdSpeed; + if(maxDownloadLimit > 0) { + thresholdSpeed = std::min(maxDownloadLimit, _thresholdSpeed); + } if(// for seeder state (_pieceStorage->downloadFinished() && _btRuntime->lessThanMaxPeers() && - (_maxUploadSpeedLimit == 0 || - tstat.getUploadSpeed() < _maxUploadSpeedLimit*0.8)) || + (maxUploadLimit == 0 || tstat.getUploadSpeed() < maxUploadLimit*0.8)) || // for leecher state (!_pieceStorage->downloadFinished() && - (tstat.getDownloadSpeed() < _thresholdSpeed || + (tstat.getDownloadSpeed() < thresholdSpeed || _btRuntime->lessThanMinPeers()))) { unsigned int numConnection = 0; |
