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>
|
2008-06-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Always remove a peer from cache in DefaultPeerStorage::returnPeer(),
|
Always remove a peer from cache in DefaultPeerStorage::returnPeer(),
|
||||||
|
|
|
@ -61,6 +61,7 @@ ActivePeerConnectionCommand::ActivePeerConnectionCommand(int cuid,
|
||||||
interval(interval),
|
interval(interval),
|
||||||
e(e),
|
e(e),
|
||||||
_thresholdSpeed(e->option->getAsInt(PREF_BT_REQUEST_PEER_SPEED_LIMIT)),
|
_thresholdSpeed(e->option->getAsInt(PREF_BT_REQUEST_PEER_SPEED_LIMIT)),
|
||||||
|
_maxUploadSpeedLimit(e->option->getAsInt(PREF_MAX_UPLOAD_LIMIT)),
|
||||||
_numNewConnection(5)
|
_numNewConnection(5)
|
||||||
{
|
{
|
||||||
unsigned int maxDownloadSpeed = e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT);
|
unsigned int maxDownloadSpeed = e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT);
|
||||||
|
@ -75,11 +76,15 @@ bool ActivePeerConnectionCommand::execute() {
|
||||||
if(btRuntime->isHalt()) {
|
if(btRuntime->isHalt()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(!pieceStorage->downloadFinished() && checkPoint.elapsed(interval)) {
|
if(checkPoint.elapsed(interval)) {
|
||||||
checkPoint.reset();
|
checkPoint.reset();
|
||||||
TransferStat tstat = peerStorage->calculateStat();
|
TransferStat tstat = peerStorage->calculateStat();
|
||||||
if(tstat.getDownloadSpeed() < _thresholdSpeed ||
|
if(// for seeder state
|
||||||
btRuntime->lessThanMinPeers()) {
|
(pieceStorage->downloadFinished() && btRuntime->lessThanMaxPeers() &&
|
||||||
|
(_maxUploadSpeedLimit == 0 || tstat.getUploadSpeed() < _maxUploadSpeedLimit)) ||
|
||||||
|
// for leecher state
|
||||||
|
(tstat.getDownloadSpeed() < _thresholdSpeed ||
|
||||||
|
btRuntime->lessThanMinPeers())) {
|
||||||
for(size_t numAdd = _numNewConnection;
|
for(size_t numAdd = _numNewConnection;
|
||||||
numAdd > 0 && peerStorage->isPeerAvailable(); --numAdd) {
|
numAdd > 0 && peerStorage->isPeerAvailable(); --numAdd) {
|
||||||
PeerHandle peer = peerStorage->getUnusedPeer();
|
PeerHandle peer = peerStorage->getUnusedPeer();
|
||||||
|
|
|
@ -54,6 +54,7 @@ private:
|
||||||
DownloadEngine* e;
|
DownloadEngine* e;
|
||||||
Time checkPoint;
|
Time checkPoint;
|
||||||
unsigned int _thresholdSpeed; // UNIT: byte/sec
|
unsigned int _thresholdSpeed; // UNIT: byte/sec
|
||||||
|
unsigned int _maxUploadSpeedLimit;
|
||||||
size_t _numNewConnection; // the number of the connection to establish.
|
size_t _numNewConnection; // the number of the connection to establish.
|
||||||
public:
|
public:
|
||||||
ActivePeerConnectionCommand(int cuid,
|
ActivePeerConnectionCommand(int cuid,
|
||||||
|
|
Loading…
Reference in New Issue