summaryrefslogtreecommitdiff
path: root/src/ActivePeerConnectionCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-06-10 11:31:35 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-06-10 11:31:35 +0000
commit46627da9a85c67892d9056a2b1cd713675689837 (patch)
tree18df0daed7c905c5dd0c18e340c2b40b78f1b5a0 /src/ActivePeerConnectionCommand.cc
parent7a74971caa34bc1fcf0c7913a09d274b039b8722 (diff)
2008-06-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Actively establish connection to peers in seeding, when peer cache is not full and max upload speed limit is not reached. * src/ActivePeerConnectionCommand.cc * src/ActivePeerConnectionCommand.h
Diffstat (limited to 'src/ActivePeerConnectionCommand.cc')
-rw-r--r--src/ActivePeerConnectionCommand.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/ActivePeerConnectionCommand.cc b/src/ActivePeerConnectionCommand.cc
index ed66412a..56aa837c 100644
--- a/src/ActivePeerConnectionCommand.cc
+++ b/src/ActivePeerConnectionCommand.cc
@@ -61,6 +61,7 @@ ActivePeerConnectionCommand::ActivePeerConnectionCommand(int cuid,
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);
@@ -75,11 +76,15 @@ bool ActivePeerConnectionCommand::execute() {
if(btRuntime->isHalt()) {
return true;
}
- if(!pieceStorage->downloadFinished() && checkPoint.elapsed(interval)) {
+ if(checkPoint.elapsed(interval)) {
checkPoint.reset();
TransferStat tstat = peerStorage->calculateStat();
- if(tstat.getDownloadSpeed() < _thresholdSpeed ||
- btRuntime->lessThanMinPeers()) {
+ if(// for seeder state
+ (pieceStorage->downloadFinished() && btRuntime->lessThanMaxPeers() &&
+ (_maxUploadSpeedLimit == 0 || tstat.getUploadSpeed() < _maxUploadSpeedLimit)) ||
+ // for leecher state
+ (tstat.getDownloadSpeed() < _thresholdSpeed ||
+ btRuntime->lessThanMinPeers())) {
for(size_t numAdd = _numNewConnection;
numAdd > 0 && peerStorage->isPeerAvailable(); --numAdd) {
PeerHandle peer = peerStorage->getUnusedPeer();