mirror of https://github.com/aria2/aria2
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.hpull/1/head
parent
7a74971caa
commit
46627da9a8
|
@ -1,3 +1,10 @@
|
|||
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
|
||||
|
||||
2008-06-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Always remove a peer from cache in DefaultPeerStorage::returnPeer(),
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue