mirror of https://github.com/aria2/aria2
2008-02-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Determin _threadtholdSpeed in each constructor for ActivePeerConnectionCommand and PeerReceiveHandshakeCommand. * src/ActivePeerConnectionCommand.{h, cc} * src/PeerReceiveHandshakeCommand.{h, cc} * src/BtSetup.cc * src/BtConstants.hpull/1/head
parent
20cd2e5246
commit
3c41ea24bf
|
@ -1,3 +1,12 @@
|
||||||
|
2008-02-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Determin _threadtholdSpeed in each constructor for
|
||||||
|
ActivePeerConnectionCommand and PeerReceiveHandshakeCommand.
|
||||||
|
* src/ActivePeerConnectionCommand.{h, cc}
|
||||||
|
* src/PeerReceiveHandshakeCommand.{h, cc}
|
||||||
|
* src/BtSetup.cc
|
||||||
|
* src/BtConstants.h
|
||||||
|
|
||||||
2008-02-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-02-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Added --bt-min-crypto-level and --bt-require-crypto options.
|
Added --bt-min-crypto-level and --bt-require-crypto options.
|
||||||
|
|
|
@ -43,6 +43,9 @@
|
||||||
#include "BtRuntime.h"
|
#include "BtRuntime.h"
|
||||||
#include "Peer.h"
|
#include "Peer.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
#include "prefs.h"
|
||||||
|
#include "Option.h"
|
||||||
|
#include "BtConstants.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -50,16 +53,20 @@ ActivePeerConnectionCommand::ActivePeerConnectionCommand(int cuid,
|
||||||
RequestGroup* requestGroup,
|
RequestGroup* requestGroup,
|
||||||
DownloadEngine* e,
|
DownloadEngine* e,
|
||||||
const BtContextHandle& btContext,
|
const BtContextHandle& btContext,
|
||||||
int32_t interval,
|
int32_t interval)
|
||||||
int32_t thresholdSpeed)
|
|
||||||
:Command(cuid),
|
:Command(cuid),
|
||||||
BtContextAwareCommand(btContext),
|
BtContextAwareCommand(btContext),
|
||||||
RequestGroupAware(requestGroup),
|
RequestGroupAware(requestGroup),
|
||||||
interval(interval),
|
interval(interval),
|
||||||
e(e),
|
e(e),
|
||||||
_thresholdSpeed(thresholdSpeed),
|
_thresholdSpeed(SLOW_SPEED_THRESHOLD),
|
||||||
_numNewConnection(5)
|
_numNewConnection(5)
|
||||||
{}
|
{
|
||||||
|
int32_t maxDownloadSpeed = e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT);
|
||||||
|
if(maxDownloadSpeed > 0) {
|
||||||
|
_thresholdSpeed = std::min(maxDownloadSpeed, _thresholdSpeed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ActivePeerConnectionCommand::~ActivePeerConnectionCommand() {}
|
ActivePeerConnectionCommand::~ActivePeerConnectionCommand() {}
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,7 @@ public:
|
||||||
RequestGroup* requestGroup,
|
RequestGroup* requestGroup,
|
||||||
DownloadEngine* e,
|
DownloadEngine* e,
|
||||||
const SharedHandle<BtContext>& btContext,
|
const SharedHandle<BtContext>& btContext,
|
||||||
int32_t interval,
|
int32_t interval);
|
||||||
int32_t thresholdSpeed);
|
|
||||||
|
|
||||||
virtual ~ActivePeerConnectionCommand();
|
virtual ~ActivePeerConnectionCommand();
|
||||||
|
|
||||||
|
|
|
@ -50,4 +50,6 @@ typedef std::map<std::string, uint8_t> Extensions;
|
||||||
|
|
||||||
#define DEFAULT_LATENCY 1500
|
#define DEFAULT_LATENCY 1500
|
||||||
|
|
||||||
|
#define SLOW_SPEED_THRESHOLD (50*1024)
|
||||||
|
|
||||||
#endif // _D_BT_CONSTANTS_
|
#endif // _D_BT_CONSTANTS_
|
||||||
|
|
|
@ -80,16 +80,10 @@ Commands BtSetup::setup(RequestGroup* requestGroup,
|
||||||
e,
|
e,
|
||||||
btContext,
|
btContext,
|
||||||
10));
|
10));
|
||||||
{
|
|
||||||
int32_t thresholdSpeed = 50*1024;
|
commands.push_back(new ActivePeerConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(),
|
||||||
int32_t maxDownloadSpeed = option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT);
|
requestGroup, e, btContext, 10));
|
||||||
if(maxDownloadSpeed > 0) {
|
|
||||||
thresholdSpeed = std::min(maxDownloadSpeed, thresholdSpeed);
|
|
||||||
}
|
|
||||||
commands.push_back(new ActivePeerConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(),
|
|
||||||
requestGroup, e, btContext, 10,
|
|
||||||
thresholdSpeed));
|
|
||||||
}
|
|
||||||
if(!btContext->isPrivate() && DHTSetup::initialized()) {
|
if(!btContext->isPrivate() && DHTSetup::initialized()) {
|
||||||
DHTRegistry::_peerAnnounceStorage->addPeerAnnounce(btContext);
|
DHTRegistry::_peerAnnounceStorage->addPeerAnnounce(btContext);
|
||||||
DHTGetPeersCommand* command = new DHTGetPeersCommand(CUIDCounterSingletonHolder::instance()->newID(),
|
DHTGetPeersCommand* command = new DHTGetPeersCommand(CUIDCounterSingletonHolder::instance()->newID(),
|
||||||
|
|
|
@ -49,6 +49,8 @@
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "Socket.h"
|
#include "Socket.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
#include "prefs.h"
|
||||||
|
#include "Option.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -59,11 +61,15 @@ PeerReceiveHandshakeCommand::PeerReceiveHandshakeCommand(int32_t cuid,
|
||||||
const SharedHandle<PeerConnection>& peerConnection):
|
const SharedHandle<PeerConnection>& peerConnection):
|
||||||
PeerAbstractCommand(cuid, peer, e, s),
|
PeerAbstractCommand(cuid, peer, e, s),
|
||||||
_peerConnection(peerConnection),
|
_peerConnection(peerConnection),
|
||||||
_lowestSpeedLimit(20*1024)
|
_thresholdSpeed(SLOW_SPEED_THRESHOLD)
|
||||||
{
|
{
|
||||||
if(_peerConnection.isNull()) {
|
if(_peerConnection.isNull()) {
|
||||||
_peerConnection = new PeerConnection(cuid, socket, e->option);
|
_peerConnection = new PeerConnection(cuid, socket, e->option);
|
||||||
}
|
}
|
||||||
|
int32_t maxDownloadSpeed = e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT);
|
||||||
|
if(maxDownloadSpeed > 0) {
|
||||||
|
_thresholdSpeed = std::min(maxDownloadSpeed, _thresholdSpeed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerReceiveHandshakeCommand::~PeerReceiveHandshakeCommand() {}
|
PeerReceiveHandshakeCommand::~PeerReceiveHandshakeCommand() {}
|
||||||
|
@ -89,7 +95,8 @@ bool PeerReceiveHandshakeCommand::executeInternal()
|
||||||
throw new DlAbortEx("Unknown info hash %s", infoHash.c_str());
|
throw new DlAbortEx("Unknown info hash %s", infoHash.c_str());
|
||||||
}
|
}
|
||||||
TransferStat tstat = PEER_STORAGE(btContext)->calculateStat();
|
TransferStat tstat = PEER_STORAGE(btContext)->calculateStat();
|
||||||
if(!PIECE_STORAGE(btContext)->downloadFinished() && tstat.getDownloadSpeed() < _lowestSpeedLimit ||
|
if((!PIECE_STORAGE(btContext)->downloadFinished() &&
|
||||||
|
tstat.getDownloadSpeed() < _thresholdSpeed) ||
|
||||||
BT_RUNTIME(btContext)->getConnections() < MAX_PEERS) {
|
BT_RUNTIME(btContext)->getConnections() < MAX_PEERS) {
|
||||||
if(PEER_STORAGE(btContext)->addPeer(peer)) {
|
if(PEER_STORAGE(btContext)->addPeer(peer)) {
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ class PeerReceiveHandshakeCommand:public PeerAbstractCommand
|
||||||
private:
|
private:
|
||||||
SharedHandle<PeerConnection> _peerConnection;
|
SharedHandle<PeerConnection> _peerConnection;
|
||||||
|
|
||||||
int32_t _lowestSpeedLimit;
|
int32_t _thresholdSpeed;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool executeInternal();
|
virtual bool executeInternal();
|
||||||
|
|
Loading…
Reference in New Issue