diff --git a/ChangeLog b/ChangeLog index 492c84f6..65e3adb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-06-10 Tatsuhiro Tsujikawa + + 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 + 2008-06-10 Tatsuhiro Tsujikawa Always remove a peer from cache in DefaultPeerStorage::returnPeer(), 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(); diff --git a/src/ActivePeerConnectionCommand.h b/src/ActivePeerConnectionCommand.h index 39b03380..4414ea37 100644 --- a/src/ActivePeerConnectionCommand.h +++ b/src/ActivePeerConnectionCommand.h @@ -54,6 +54,7 @@ private: DownloadEngine* e; Time checkPoint; unsigned int _thresholdSpeed; // UNIT: byte/sec + unsigned int _maxUploadSpeedLimit; size_t _numNewConnection; // the number of the connection to establish. public: ActivePeerConnectionCommand(int cuid,