瀏覽代碼

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
Tatsuhiro Tsujikawa 17 年之前
父節點
當前提交
a12be22ecb
共有 2 個文件被更改,包括 17 次插入4 次删除
  1. 7 0
      ChangeLog
  2. 10 4
      src/ActivePeerConnectionCommand.cc

+ 7 - 0
ChangeLog

@@ -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.

+ 10 - 4
src/ActivePeerConnectionCommand.cc

@@ -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);