2008-08-23 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Fixed the bug that the number of connected peer is exceeding the 
limit
	(55 by default) in seeding mode.
	Multiplied 0.8 to _maxUploadSpeedLimit.
	* src/ActivePeerConnectionCommand.cc
pull/1/head
Tatsuhiro Tsujikawa 2008-08-23 15:17:32 +00:00
parent df9d042d25
commit a12be22ecb
2 changed files with 17 additions and 4 deletions

View File

@ -1,3 +1,10 @@
2008-08-23 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the bug that the number of connected peer is exceeding the limit
(55 by default) in seeding mode.
Multiplied 0.8 to _maxUploadSpeedLimit.
* src/ActivePeerConnectionCommand.cc
2008-08-23 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Clear table item.

View File

@ -81,11 +81,17 @@ bool ActivePeerConnectionCommand::execute() {
TransferStat tstat = peerStorage->calculateStat();
if(// for seeder state
(pieceStorage->downloadFinished() && btRuntime->lessThanMaxPeers() &&
(_maxUploadSpeedLimit == 0 || tstat.getUploadSpeed() < _maxUploadSpeedLimit)) ||
(_maxUploadSpeedLimit == 0 ||
tstat.getUploadSpeed() < _maxUploadSpeedLimit*0.8)) ||
// for leecher state
(tstat.getDownloadSpeed() < _thresholdSpeed ||
btRuntime->lessThanMinPeers())) {
for(size_t numAdd = _numNewConnection;
(!pieceStorage->downloadFinished() &&
(tstat.getDownloadSpeed() < _thresholdSpeed ||
btRuntime->lessThanMinPeers()))) {
size_t numConnection = pieceStorage->downloadFinished() ?
std::min(_numNewConnection,
BtRuntime::MAX_PEERS-btRuntime->getConnections()) :
_numNewConnection;
for(size_t numAdd = numConnection;
numAdd > 0 && peerStorage->isPeerAvailable(); --numAdd) {
PeerHandle peer = peerStorage->getUnusedPeer();
connectToPeer(peer);