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
pull/1/head
Tatsuhiro Tsujikawa 2008-02-18 17:11:44 +00:00
parent 20cd2e5246
commit 3c41ea24bf
7 changed files with 37 additions and 19 deletions

View File

@ -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>
Added --bt-min-crypto-level and --bt-require-crypto options.

View File

@ -43,6 +43,9 @@
#include "BtRuntime.h"
#include "Peer.h"
#include "Logger.h"
#include "prefs.h"
#include "Option.h"
#include "BtConstants.h"
namespace aria2 {
@ -50,16 +53,20 @@ ActivePeerConnectionCommand::ActivePeerConnectionCommand(int cuid,
RequestGroup* requestGroup,
DownloadEngine* e,
const BtContextHandle& btContext,
int32_t interval,
int32_t thresholdSpeed)
int32_t interval)
:Command(cuid),
BtContextAwareCommand(btContext),
RequestGroupAware(requestGroup),
interval(interval),
e(e),
_thresholdSpeed(thresholdSpeed),
_thresholdSpeed(SLOW_SPEED_THRESHOLD),
_numNewConnection(5)
{}
{
int32_t maxDownloadSpeed = e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT);
if(maxDownloadSpeed > 0) {
_thresholdSpeed = std::min(maxDownloadSpeed, _thresholdSpeed);
}
}
ActivePeerConnectionCommand::~ActivePeerConnectionCommand() {}

View File

@ -60,8 +60,7 @@ public:
RequestGroup* requestGroup,
DownloadEngine* e,
const SharedHandle<BtContext>& btContext,
int32_t interval,
int32_t thresholdSpeed);
int32_t interval);
virtual ~ActivePeerConnectionCommand();

View File

@ -50,4 +50,6 @@ typedef std::map<std::string, uint8_t> Extensions;
#define DEFAULT_LATENCY 1500
#define SLOW_SPEED_THRESHOLD (50*1024)
#endif // _D_BT_CONSTANTS_

View File

@ -80,16 +80,10 @@ Commands BtSetup::setup(RequestGroup* requestGroup,
e,
btContext,
10));
{
int32_t thresholdSpeed = 50*1024;
int32_t maxDownloadSpeed = option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT);
if(maxDownloadSpeed > 0) {
thresholdSpeed = std::min(maxDownloadSpeed, thresholdSpeed);
}
commands.push_back(new ActivePeerConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(),
requestGroup, e, btContext, 10,
thresholdSpeed));
}
commands.push_back(new ActivePeerConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(),
requestGroup, e, btContext, 10));
if(!btContext->isPrivate() && DHTSetup::initialized()) {
DHTRegistry::_peerAnnounceStorage->addPeerAnnounce(btContext);
DHTGetPeersCommand* command = new DHTGetPeersCommand(CUIDCounterSingletonHolder::instance()->newID(),

View File

@ -49,6 +49,8 @@
#include "message.h"
#include "Socket.h"
#include "Logger.h"
#include "prefs.h"
#include "Option.h"
namespace aria2 {
@ -59,11 +61,15 @@ PeerReceiveHandshakeCommand::PeerReceiveHandshakeCommand(int32_t cuid,
const SharedHandle<PeerConnection>& peerConnection):
PeerAbstractCommand(cuid, peer, e, s),
_peerConnection(peerConnection),
_lowestSpeedLimit(20*1024)
_thresholdSpeed(SLOW_SPEED_THRESHOLD)
{
if(_peerConnection.isNull()) {
_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() {}
@ -89,7 +95,8 @@ bool PeerReceiveHandshakeCommand::executeInternal()
throw new DlAbortEx("Unknown info hash %s", infoHash.c_str());
}
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) {
if(PEER_STORAGE(btContext)->addPeer(peer)) {

View File

@ -48,7 +48,7 @@ class PeerReceiveHandshakeCommand:public PeerAbstractCommand
private:
SharedHandle<PeerConnection> _peerConnection;
int32_t _lowestSpeedLimit;
int32_t _thresholdSpeed;
protected:
virtual bool executeInternal();