mirror of https://github.com/aria2/aria2
Use int instead of unsigned int where unsigned int is not needed.
parent
b97a7c8ecf
commit
f0bcfa822e
|
@ -320,7 +320,7 @@ bool AbstractCommand::execute() {
|
||||||
req_->addTryCount();
|
req_->addTryCount();
|
||||||
req_->resetRedirectCount();
|
req_->resetRedirectCount();
|
||||||
req_->resetUri();
|
req_->resetUri();
|
||||||
const unsigned int maxTries = getOption()->getAsInt(PREF_MAX_TRIES);
|
const int maxTries = getOption()->getAsInt(PREF_MAX_TRIES);
|
||||||
bool isAbort = maxTries != 0 && req_->getTryCount() >= maxTries;
|
bool isAbort = maxTries != 0 && req_->getTryCount() >= maxTries;
|
||||||
if(isAbort) {
|
if(isAbort) {
|
||||||
A2_LOG_INFO(fmt(MSG_MAX_TRY,
|
A2_LOG_INFO(fmt(MSG_MAX_TRY,
|
||||||
|
|
|
@ -82,10 +82,9 @@ bool ActivePeerConnectionCommand::execute() {
|
||||||
if(checkPoint_.difference(global::wallclock()) >= interval_) {
|
if(checkPoint_.difference(global::wallclock()) >= interval_) {
|
||||||
checkPoint_ = global::wallclock();
|
checkPoint_ = global::wallclock();
|
||||||
TransferStat tstat = requestGroup_->calculateStat();
|
TransferStat tstat = requestGroup_->calculateStat();
|
||||||
const unsigned int maxDownloadLimit =
|
const int maxDownloadLimit = requestGroup_->getMaxDownloadSpeedLimit();
|
||||||
requestGroup_->getMaxDownloadSpeedLimit();
|
const int maxUploadLimit = requestGroup_->getMaxUploadSpeedLimit();
|
||||||
const unsigned int maxUploadLimit = requestGroup_->getMaxUploadSpeedLimit();
|
int thresholdSpeed;
|
||||||
unsigned int thresholdSpeed;
|
|
||||||
if(!bittorrent::getTorrentAttrs
|
if(!bittorrent::getTorrentAttrs
|
||||||
(requestGroup_->getDownloadContext())->metadata.empty()) {
|
(requestGroup_->getDownloadContext())->metadata.empty()) {
|
||||||
thresholdSpeed =
|
thresholdSpeed =
|
||||||
|
@ -104,7 +103,7 @@ bool ActivePeerConnectionCommand::execute() {
|
||||||
(tstat.getDownloadSpeed() < thresholdSpeed ||
|
(tstat.getDownloadSpeed() < thresholdSpeed ||
|
||||||
btRuntime_->lessThanMinPeers()))) {
|
btRuntime_->lessThanMinPeers()))) {
|
||||||
|
|
||||||
unsigned int numConnection = 0;
|
int numConnection = 0;
|
||||||
if(pieceStorage_->downloadFinished()) {
|
if(pieceStorage_->downloadFinished()) {
|
||||||
if(btRuntime_->getMaxPeers() > btRuntime_->getConnections()) {
|
if(btRuntime_->getMaxPeers() > btRuntime_->getConnections()) {
|
||||||
numConnection =
|
numConnection =
|
||||||
|
@ -115,7 +114,7 @@ bool ActivePeerConnectionCommand::execute() {
|
||||||
numConnection = numNewConnection_;
|
numConnection = numNewConnection_;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(unsigned int numAdd = numConnection;
|
for(int numAdd = numConnection;
|
||||||
numAdd > 0 && peerStorage_->isPeerAvailable(); --numAdd) {
|
numAdd > 0 && peerStorage_->isPeerAvailable(); --numAdd) {
|
||||||
SharedHandle<Peer> peer = peerStorage_->getUnusedPeer();
|
SharedHandle<Peer> peer = peerStorage_->getUnusedPeer();
|
||||||
connectToPeer(peer);
|
connectToPeer(peer);
|
||||||
|
|
|
@ -60,7 +60,7 @@ private:
|
||||||
time_t interval_; // UNIT: sec
|
time_t interval_; // UNIT: sec
|
||||||
DownloadEngine* e_;
|
DownloadEngine* e_;
|
||||||
Timer checkPoint_;
|
Timer checkPoint_;
|
||||||
unsigned int numNewConnection_; // the number of the connection to establish.
|
int numNewConnection_; // the number of the connection to establish.
|
||||||
public:
|
public:
|
||||||
ActivePeerConnectionCommand(cuid_t cuid,
|
ActivePeerConnectionCommand(cuid_t cuid,
|
||||||
RequestGroup* requestGroup,
|
RequestGroup* requestGroup,
|
||||||
|
@ -73,7 +73,7 @@ public:
|
||||||
|
|
||||||
void connectToPeer(const SharedHandle<Peer>& peer);
|
void connectToPeer(const SharedHandle<Peer>& peer);
|
||||||
|
|
||||||
void setNumNewConnection(size_t numNewConnection)
|
void setNumNewConnection(int numNewConnection)
|
||||||
{
|
{
|
||||||
numNewConnection_ = numNewConnection;
|
numNewConnection_ = numNewConnection;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,12 +125,13 @@ std::string AdaptiveURISelector::selectOne(const std::deque<std::string>& uris)
|
||||||
if(uris.empty()) {
|
if(uris.empty()) {
|
||||||
return A2STR::NIL;
|
return A2STR::NIL;
|
||||||
} else {
|
} else {
|
||||||
const unsigned int numPieces =
|
const size_t numPieces =
|
||||||
requestGroup_->getDownloadContext()->getNumPieces();
|
requestGroup_->getDownloadContext()->getNumPieces();
|
||||||
|
|
||||||
bool reservedContext = numPieces > 0 &&
|
bool reservedContext = numPieces > 0 &&
|
||||||
nbConnections_ > std::min(numPieces,
|
static_cast<size_t>(nbConnections_) > std::min
|
||||||
requestGroup_->getNumConcurrentCommand());
|
(numPieces,
|
||||||
|
static_cast<size_t>(requestGroup_->getNumConcurrentCommand()));
|
||||||
bool selectBest = numPieces == 0 || reservedContext;
|
bool selectBest = numPieces == 0 || reservedContext;
|
||||||
|
|
||||||
if(numPieces > 0)
|
if(numPieces > 0)
|
||||||
|
@ -180,8 +181,8 @@ std::string AdaptiveURISelector::getBestMirror
|
||||||
(const std::deque<std::string>& uris) const
|
(const std::deque<std::string>& uris) const
|
||||||
{
|
{
|
||||||
/* Here we return one of the bests mirrors */
|
/* Here we return one of the bests mirrors */
|
||||||
unsigned int max = getMaxDownloadSpeed(uris);
|
int max = getMaxDownloadSpeed(uris);
|
||||||
unsigned int min = max-(int)(max*0.25);
|
int min = max-(int)(max*0.25);
|
||||||
std::deque<std::string> bests = getUrisBySpeed(uris, min);
|
std::deque<std::string> bests = getUrisBySpeed(uris, min);
|
||||||
|
|
||||||
if (bests.size() < 2) {
|
if (bests.size() < 2) {
|
||||||
|
@ -218,11 +219,11 @@ void AdaptiveURISelector::tuneDownloadCommand
|
||||||
void AdaptiveURISelector::adjustLowestSpeedLimit
|
void AdaptiveURISelector::adjustLowestSpeedLimit
|
||||||
(const std::deque<std::string>& uris, DownloadCommand* command) const
|
(const std::deque<std::string>& uris, DownloadCommand* command) const
|
||||||
{
|
{
|
||||||
unsigned int lowest =
|
int lowest =
|
||||||
requestGroup_->getOption()->getAsInt(PREF_LOWEST_SPEED_LIMIT);
|
requestGroup_->getOption()->getAsInt(PREF_LOWEST_SPEED_LIMIT);
|
||||||
if (lowest > 0) {
|
if (lowest > 0) {
|
||||||
unsigned int low_lowest = 4 * 1024;
|
int low_lowest = 4 * 1024;
|
||||||
unsigned int max = getMaxDownloadSpeed(uris);
|
int max = getMaxDownloadSpeed(uris);
|
||||||
if (max > 0 && lowest > max / 4) {
|
if (max > 0 && lowest > max / 4) {
|
||||||
A2_LOG_NOTICE(fmt(_("Lowering lowest-speed-limit since known max speed is"
|
A2_LOG_NOTICE(fmt(_("Lowering lowest-speed-limit since known max speed is"
|
||||||
" too near (new:%d was:%d max:%d)"),
|
" too near (new:%d was:%d max:%d)"),
|
||||||
|
@ -241,14 +242,14 @@ void AdaptiveURISelector::adjustLowestSpeedLimit
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
unsigned int getUriMaxSpeed(SharedHandle<ServerStat> ss)
|
int getUriMaxSpeed(SharedHandle<ServerStat> ss)
|
||||||
{
|
{
|
||||||
return std::max(ss->getSingleConnectionAvgSpeed(),
|
return std::max(ss->getSingleConnectionAvgSpeed(),
|
||||||
ss->getMultiConnectionAvgSpeed());
|
ss->getMultiConnectionAvgSpeed());
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
unsigned int AdaptiveURISelector::getMaxDownloadSpeed
|
int AdaptiveURISelector::getMaxDownloadSpeed
|
||||||
(const std::deque<std::string>& uris) const
|
(const std::deque<std::string>& uris) const
|
||||||
{
|
{
|
||||||
std::string uri = getMaxDownloadSpeedUri(uris);
|
std::string uri = getMaxDownloadSpeedUri(uris);
|
||||||
|
@ -281,7 +282,7 @@ std::string AdaptiveURISelector::getMaxDownloadSpeedUri
|
||||||
}
|
}
|
||||||
|
|
||||||
std::deque<std::string> AdaptiveURISelector::getUrisBySpeed
|
std::deque<std::string> AdaptiveURISelector::getUrisBySpeed
|
||||||
(const std::deque<std::string>& uris, unsigned int min) const
|
(const std::deque<std::string>& uris, int min) const
|
||||||
{
|
{
|
||||||
std::deque<std::string> bests;
|
std::deque<std::string> bests;
|
||||||
for(std::deque<std::string>::const_iterator i = uris.begin(),
|
for(std::deque<std::string>::const_iterator i = uris.begin(),
|
||||||
|
@ -321,7 +322,7 @@ std::string AdaptiveURISelector::getFirstNotTestedUri
|
||||||
std::string AdaptiveURISelector::getFirstToTestUri
|
std::string AdaptiveURISelector::getFirstToTestUri
|
||||||
(const std::deque<std::string>& uris) const
|
(const std::deque<std::string>& uris) const
|
||||||
{
|
{
|
||||||
unsigned int counter;
|
int counter;
|
||||||
int power;
|
int power;
|
||||||
for(std::deque<std::string>::const_iterator i = uris.begin(),
|
for(std::deque<std::string>::const_iterator i = uris.begin(),
|
||||||
eoi = uris.end(); i != eoi; ++i) {
|
eoi = uris.end(); i != eoi; ++i) {
|
||||||
|
@ -352,10 +353,10 @@ SharedHandle<ServerStat> AdaptiveURISelector::getServerStats
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int AdaptiveURISelector::getNbTestedServers
|
int AdaptiveURISelector::getNbTestedServers
|
||||||
(const std::deque<std::string>& uris) const
|
(const std::deque<std::string>& uris) const
|
||||||
{
|
{
|
||||||
unsigned int counter = 0;
|
int counter = 0;
|
||||||
for(std::deque<std::string>::const_iterator i = uris.begin(),
|
for(std::deque<std::string>::const_iterator i = uris.begin(),
|
||||||
eoi = uris.end(); i != eoi; ++i) {
|
eoi = uris.end(); i != eoi; ++i) {
|
||||||
SharedHandle<ServerStat> ss = getServerStats(*i);
|
SharedHandle<ServerStat> ss = getServerStats(*i);
|
||||||
|
|
|
@ -49,8 +49,8 @@ private:
|
||||||
SharedHandle<ServerStatMan> serverStatMan_;
|
SharedHandle<ServerStatMan> serverStatMan_;
|
||||||
// No need to delete requestGroup_
|
// No need to delete requestGroup_
|
||||||
RequestGroup* requestGroup_;
|
RequestGroup* requestGroup_;
|
||||||
unsigned int nbServerToEvaluate_;
|
int nbServerToEvaluate_;
|
||||||
unsigned int nbConnections_;
|
int nbConnections_;
|
||||||
|
|
||||||
static const time_t MAX_TIMEOUT = 60;
|
static const time_t MAX_TIMEOUT = 60;
|
||||||
|
|
||||||
|
@ -59,15 +59,15 @@ private:
|
||||||
std::string selectOne(const std::deque<std::string>& uris);
|
std::string selectOne(const std::deque<std::string>& uris);
|
||||||
void adjustLowestSpeedLimit(const std::deque<std::string>& uris,
|
void adjustLowestSpeedLimit(const std::deque<std::string>& uris,
|
||||||
DownloadCommand* command) const;
|
DownloadCommand* command) const;
|
||||||
unsigned int getMaxDownloadSpeed(const std::deque<std::string>& uris) const;
|
int getMaxDownloadSpeed(const std::deque<std::string>& uris) const;
|
||||||
std::string getMaxDownloadSpeedUri(const std::deque<std::string>& uris) const;
|
std::string getMaxDownloadSpeedUri(const std::deque<std::string>& uris) const;
|
||||||
std::deque<std::string> getUrisBySpeed(const std::deque<std::string>& uris,
|
std::deque<std::string> getUrisBySpeed(const std::deque<std::string>& uris,
|
||||||
unsigned int min) const;
|
int min) const;
|
||||||
std::string selectRandomUri(const std::deque<std::string>& uris) const;
|
std::string selectRandomUri(const std::deque<std::string>& uris) const;
|
||||||
std::string getFirstNotTestedUri(const std::deque<std::string>& uris) const;
|
std::string getFirstNotTestedUri(const std::deque<std::string>& uris) const;
|
||||||
std::string getFirstToTestUri(const std::deque<std::string>& uris) const;
|
std::string getFirstToTestUri(const std::deque<std::string>& uris) const;
|
||||||
SharedHandle<ServerStat> getServerStats(const std::string& uri) const;
|
SharedHandle<ServerStat> getServerStats(const std::string& uri) const;
|
||||||
unsigned int getNbTestedServers(const std::deque<std::string>& uris) const;
|
int getNbTestedServers(const std::deque<std::string>& uris) const;
|
||||||
std::string getBestMirror(const std::deque<std::string>& uris) const;
|
std::string getBestMirror(const std::deque<std::string>& uris) const;
|
||||||
public:
|
public:
|
||||||
AdaptiveURISelector(const SharedHandle<ServerStatMan>& serverStatMan,
|
AdaptiveURISelector(const SharedHandle<ServerStatMan>& serverStatMan,
|
||||||
|
|
|
@ -91,7 +91,7 @@ const SharedHandle<Peer>& BtLeecherStateChoke::PeerEntry::getPeer() const
|
||||||
return peer_;
|
return peer_;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int BtLeecherStateChoke::PeerEntry::getDownloadSpeed() const
|
int BtLeecherStateChoke::PeerEntry::getDownloadSpeed() const
|
||||||
{
|
{
|
||||||
return downloadSpeed_;
|
return downloadSpeed_;
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ void BtLeecherStateChoke::regularUnchoke(std::vector<PeerEntry>& peerEntries)
|
||||||
std::vector<PeerEntry>::iterator peerIter = peerEntries.begin();
|
std::vector<PeerEntry>::iterator peerIter = peerEntries.begin();
|
||||||
for(;peerIter != rest && count; ++peerIter, --count) {
|
for(;peerIter != rest && count; ++peerIter, --count) {
|
||||||
(*peerIter).disableChokingRequired();
|
(*peerIter).disableChokingRequired();
|
||||||
A2_LOG_INFO(fmt("RU: %s, dlspd=%u",
|
A2_LOG_INFO(fmt("RU: %s, dlspd=%d",
|
||||||
(*peerIter).getPeer()->getIPAddress().c_str(),
|
(*peerIter).getPeer()->getIPAddress().c_str(),
|
||||||
(*peerIter).getDownloadSpeed()));
|
(*peerIter).getDownloadSpeed()));
|
||||||
if((*peerIter).getPeer()->optUnchoking()) {
|
if((*peerIter).getPeer()->optUnchoking()) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ private:
|
||||||
class PeerEntry {
|
class PeerEntry {
|
||||||
private:
|
private:
|
||||||
SharedHandle<Peer> peer_;
|
SharedHandle<Peer> peer_;
|
||||||
unsigned int downloadSpeed_;
|
int downloadSpeed_;
|
||||||
bool regularUnchoker_;
|
bool regularUnchoker_;
|
||||||
public:
|
public:
|
||||||
PeerEntry(const SharedHandle<Peer>& peer);
|
PeerEntry(const SharedHandle<Peer>& peer);
|
||||||
|
@ -70,7 +70,7 @@ private:
|
||||||
|
|
||||||
const SharedHandle<Peer>& getPeer() const;
|
const SharedHandle<Peer>& getPeer() const;
|
||||||
|
|
||||||
unsigned int getDownloadSpeed() const;
|
int getDownloadSpeed() const;
|
||||||
|
|
||||||
bool isRegularUnchoker() const;
|
bool isRegularUnchoker() const;
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ void BtPieceMessage::doReceivedAction()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
A2_LOG_DEBUG(fmt("CUID#%lld - RequestSlot not found, index=%lu, begin=%u",
|
A2_LOG_DEBUG(fmt("CUID#%lld - RequestSlot not found, index=%lu, begin=%d",
|
||||||
getCuid(),
|
getCuid(),
|
||||||
static_cast<unsigned long>(index_),
|
static_cast<unsigned long>(index_),
|
||||||
begin_));
|
begin_));
|
||||||
|
|
|
@ -48,10 +48,10 @@ BtRuntime::BtRuntime()
|
||||||
|
|
||||||
BtRuntime::~BtRuntime() {}
|
BtRuntime::~BtRuntime() {}
|
||||||
|
|
||||||
void BtRuntime::setMaxPeers(unsigned int maxPeers)
|
void BtRuntime::setMaxPeers(int maxPeers)
|
||||||
{
|
{
|
||||||
maxPeers_ = maxPeers;
|
maxPeers_ = maxPeers;
|
||||||
minPeers_ = static_cast<unsigned int>(maxPeers*0.8);
|
minPeers_ = maxPeers*0.8;
|
||||||
if(minPeers_ == 0 && maxPeers != 0) {
|
if(minPeers_ == 0 && maxPeers != 0) {
|
||||||
minPeers_ = maxPeers;
|
minPeers_ = maxPeers;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,17 +44,14 @@ class BtRuntime {
|
||||||
private:
|
private:
|
||||||
off_t uploadLengthAtStartup_;
|
off_t uploadLengthAtStartup_;
|
||||||
bool halt_;
|
bool halt_;
|
||||||
unsigned int connections_;
|
int connections_;
|
||||||
bool ready_;
|
bool ready_;
|
||||||
// Maximum number of peers to hold connections at the same time.
|
// Maximum number of peers to hold connections at the same time.
|
||||||
// 0 means unlimited.
|
// 0 means unlimited.
|
||||||
unsigned int maxPeers_;
|
int maxPeers_;
|
||||||
// Minimum number of peers. This value is used for getting more peers from
|
// Minimum number of peers. This value is used for getting more peers from
|
||||||
// tracker. 0 means always the number of peers is under minimum.
|
// tracker. 0 means always the number of peers is under minimum.
|
||||||
unsigned int minPeers_;
|
int minPeers_;
|
||||||
|
|
||||||
static const unsigned int DEFAULT_MIN_PEERS = 40;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BtRuntime();
|
BtRuntime();
|
||||||
|
|
||||||
|
@ -74,7 +71,7 @@ public:
|
||||||
halt_ = halt;
|
halt_ = halt;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getConnections() const { return connections_; }
|
int getConnections() const { return connections_; }
|
||||||
|
|
||||||
void increaseConnections() { ++connections_; }
|
void increaseConnections() { ++connections_; }
|
||||||
|
|
||||||
|
@ -99,14 +96,15 @@ public:
|
||||||
|
|
||||||
void setReady(bool go) { ready_ = go; }
|
void setReady(bool go) { ready_ = go; }
|
||||||
|
|
||||||
void setMaxPeers(unsigned int maxPeers);
|
void setMaxPeers(int maxPeers);
|
||||||
|
|
||||||
unsigned int getMaxPeers() const
|
int getMaxPeers() const
|
||||||
{
|
{
|
||||||
return maxPeers_;
|
return maxPeers_;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const unsigned int DEFAULT_MAX_PEERS = 55;
|
static const int DEFAULT_MAX_PEERS = 55;
|
||||||
|
static const int DEFAULT_MIN_PEERS = 40;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<BtRuntime> BtRuntimeHandle;
|
typedef SharedHandle<BtRuntime> BtRuntimeHandle;
|
||||||
|
|
|
@ -134,7 +134,7 @@ void BtSeederStateChoke::unchoke
|
||||||
for(std::vector<PeerEntry>::iterator eoi = peers.end();
|
for(std::vector<PeerEntry>::iterator eoi = peers.end();
|
||||||
r != eoi && count; ++r, --count) {
|
r != eoi && count; ++r, --count) {
|
||||||
(*r).getPeer()->chokingRequired(false);
|
(*r).getPeer()->chokingRequired(false);
|
||||||
A2_LOG_INFO(fmt("RU: %s, ulspd=%u",
|
A2_LOG_INFO(fmt("RU: %s, ulspd=%d",
|
||||||
(*r).getPeer()->getIPAddress().c_str(),
|
(*r).getPeer()->getIPAddress().c_str(),
|
||||||
(*r).getUploadSpeed()));
|
(*r).getUploadSpeed()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ private:
|
||||||
size_t outstandingUpload_;
|
size_t outstandingUpload_;
|
||||||
Timer lastAmUnchoking_;
|
Timer lastAmUnchoking_;
|
||||||
bool recentUnchoking_;
|
bool recentUnchoking_;
|
||||||
unsigned int uploadSpeed_;
|
int uploadSpeed_;
|
||||||
|
|
||||||
const static time_t TIME_FRAME = 20;
|
const static time_t TIME_FRAME = 20;
|
||||||
public:
|
public:
|
||||||
|
@ -74,7 +74,7 @@ private:
|
||||||
|
|
||||||
const SharedHandle<Peer>& getPeer() const { return peer_; }
|
const SharedHandle<Peer>& getPeer() const { return peer_; }
|
||||||
|
|
||||||
unsigned int getUploadSpeed() const { return uploadSpeed_; }
|
int getUploadSpeed() const { return uploadSpeed_; }
|
||||||
|
|
||||||
void disableOptUnchoking();
|
void disableOptUnchoking();
|
||||||
};
|
};
|
||||||
|
|
|
@ -101,7 +101,7 @@ void printProgress
|
||||||
const SizeFormatter& sizeFormatter)
|
const SizeFormatter& sizeFormatter)
|
||||||
{
|
{
|
||||||
TransferStat stat = rg->calculateStat();
|
TransferStat stat = rg->calculateStat();
|
||||||
unsigned int eta = 0;
|
int eta = 0;
|
||||||
if(rg->getTotalLength() > 0 && stat.getDownloadSpeed() > 0) {
|
if(rg->getTotalLength() > 0 && stat.getDownloadSpeed() > 0) {
|
||||||
eta = (rg->getTotalLength()-rg->getCompletedLength())/stat.getDownloadSpeed();
|
eta = (rg->getTotalLength()-rg->getCompletedLength())/stat.getDownloadSpeed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
// Increment this if major improvements or bug fixes are made in DHT
|
// Increment this if major improvements or bug fixes are made in DHT
|
||||||
// code. This is 2 bytes unsigned integer.
|
// code. This is 2 bytes unsigned integer.
|
||||||
#define DHT_VERSION 3
|
#define DHT_VERSION 3U
|
||||||
|
|
||||||
#define DHT_ID_LENGTH 20
|
#define DHT_ID_LENGTH 20
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ void DHTNode::timeout()
|
||||||
|
|
||||||
std::string DHTNode::toString() const
|
std::string DHTNode::toString() const
|
||||||
{
|
{
|
||||||
return fmt("DHTNode ID=%s, Host=%s(%u), Condition=%u, RTT=%u",
|
return fmt("DHTNode ID=%s, Host=%s(%u), Condition=%d, RTT=%d",
|
||||||
util::toHex(id_, DHT_ID_LENGTH).c_str(),
|
util::toHex(id_, DHT_ID_LENGTH).c_str(),
|
||||||
ipaddr_.c_str(),
|
ipaddr_.c_str(),
|
||||||
port_,
|
port_,
|
||||||
|
|
|
@ -54,9 +54,9 @@ private:
|
||||||
uint16_t port_;
|
uint16_t port_;
|
||||||
|
|
||||||
// in milli sec
|
// in milli sec
|
||||||
unsigned int rtt_;
|
int rtt_;
|
||||||
|
|
||||||
unsigned int condition_;
|
int condition_;
|
||||||
|
|
||||||
Timer lastContact_;
|
Timer lastContact_;
|
||||||
public:
|
public:
|
||||||
|
@ -76,7 +76,7 @@ public:
|
||||||
return id_;
|
return id_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateRTT(unsigned int millisec)
|
void updateRTT(int millisec)
|
||||||
{
|
{
|
||||||
rtt_ = millisec;
|
rtt_ = millisec;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ std::string DefaultBtAnnounce::getAnnounceUrl() {
|
||||||
} else {
|
} else {
|
||||||
return A2STR::NIL;
|
return A2STR::NIL;
|
||||||
}
|
}
|
||||||
unsigned int numWant = 50;
|
int numWant = 50;
|
||||||
if(!btRuntime_->lessThanMinPeers() || btRuntime_->isHalt()) {
|
if(!btRuntime_->lessThanMinPeers() || btRuntime_->isHalt()) {
|
||||||
numWant = 0;
|
numWant = 0;
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ std::string DefaultBtAnnounce::getAnnounceUrl() {
|
||||||
"left=%lld&"
|
"left=%lld&"
|
||||||
"compact=1&"
|
"compact=1&"
|
||||||
"key=%s&"
|
"key=%s&"
|
||||||
"numwant=%u&"
|
"numwant=%d&"
|
||||||
"no_peer_id=1",
|
"no_peer_id=1",
|
||||||
util::torrentPercentEncode
|
util::torrentPercentEncode
|
||||||
(bittorrent::getInfoHash(downloadContext_),
|
(bittorrent::getInfoHash(downloadContext_),
|
||||||
|
|
|
@ -51,13 +51,13 @@ class Randomizer;
|
||||||
class DefaultBtAnnounce : public BtAnnounce {
|
class DefaultBtAnnounce : public BtAnnounce {
|
||||||
private:
|
private:
|
||||||
SharedHandle<DownloadContext> downloadContext_;
|
SharedHandle<DownloadContext> downloadContext_;
|
||||||
unsigned int trackers_;
|
int trackers_;
|
||||||
Timer prevAnnounceTimer_;
|
Timer prevAnnounceTimer_;
|
||||||
time_t interval_;
|
time_t interval_;
|
||||||
time_t minInterval_;
|
time_t minInterval_;
|
||||||
time_t userDefinedInterval_;
|
time_t userDefinedInterval_;
|
||||||
unsigned int complete_;
|
int complete_;
|
||||||
unsigned int incomplete_;
|
int incomplete_;
|
||||||
AnnounceList announceList_;
|
AnnounceList announceList_;
|
||||||
std::string trackerId_;
|
std::string trackerId_;
|
||||||
const Option* option_;
|
const Option* option_;
|
||||||
|
@ -139,12 +139,12 @@ public:
|
||||||
return minInterval_;
|
return minInterval_;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getComplete() const
|
int getComplete() const
|
||||||
{
|
{
|
||||||
return complete_;
|
return complete_;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getIncomplete() const
|
int getIncomplete() const
|
||||||
{
|
{
|
||||||
return incomplete_;
|
return incomplete_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,28 +64,28 @@ class UTMetadataRequestTracker;
|
||||||
|
|
||||||
class FloodingStat {
|
class FloodingStat {
|
||||||
private:
|
private:
|
||||||
unsigned int chokeUnchokeCount;
|
int chokeUnchokeCount;
|
||||||
unsigned int keepAliveCount;
|
int keepAliveCount;
|
||||||
public:
|
public:
|
||||||
FloodingStat():chokeUnchokeCount(0), keepAliveCount(0) {}
|
FloodingStat():chokeUnchokeCount(0), keepAliveCount(0) {}
|
||||||
|
|
||||||
void incChokeUnchokeCount() {
|
void incChokeUnchokeCount() {
|
||||||
if(chokeUnchokeCount < UINT_MAX) {
|
if(chokeUnchokeCount < INT_MAX) {
|
||||||
chokeUnchokeCount++;
|
chokeUnchokeCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void incKeepAliveCount() {
|
void incKeepAliveCount() {
|
||||||
if(keepAliveCount < UINT_MAX) {
|
if(keepAliveCount < INT_MAX) {
|
||||||
keepAliveCount++;
|
keepAliveCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getChokeUnchokeCount() const {
|
int getChokeUnchokeCount() const {
|
||||||
return chokeUnchokeCount;
|
return chokeUnchokeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getKeepAliveCount() const {
|
int getKeepAliveCount() const {
|
||||||
return keepAliveCount;
|
return keepAliveCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,7 @@ void DownloadCommand::checkLowestDownloadSpeed() const
|
||||||
if(lowestDownloadSpeedLimit_ > 0 &&
|
if(lowestDownloadSpeedLimit_ > 0 &&
|
||||||
peerStat_->getDownloadStartTime().difference(global::wallclock()) >=
|
peerStat_->getDownloadStartTime().difference(global::wallclock()) >=
|
||||||
startupIdleTime_) {
|
startupIdleTime_) {
|
||||||
unsigned int nowSpeed = peerStat_->calculateDownloadSpeed();
|
int nowSpeed = peerStat_->calculateDownloadSpeed();
|
||||||
if(nowSpeed <= lowestDownloadSpeedLimit_) {
|
if(nowSpeed <= lowestDownloadSpeedLimit_) {
|
||||||
throw DL_ABORT_EX2(fmt(EX_TOO_SLOW_DOWNLOAD_SPEED,
|
throw DL_ABORT_EX2(fmt(EX_TOO_SLOW_DOWNLOAD_SPEED,
|
||||||
nowSpeed,
|
nowSpeed,
|
||||||
|
|
|
@ -50,7 +50,7 @@ class MessageDigest;
|
||||||
class DownloadCommand : public AbstractCommand {
|
class DownloadCommand : public AbstractCommand {
|
||||||
private:
|
private:
|
||||||
time_t startupIdleTime_;
|
time_t startupIdleTime_;
|
||||||
unsigned int lowestDownloadSpeedLimit_;
|
int lowestDownloadSpeedLimit_;
|
||||||
SharedHandle<PeerStat> peerStat_;
|
SharedHandle<PeerStat> peerStat_;
|
||||||
|
|
||||||
bool pieceHashValidationEnabled_;
|
bool pieceHashValidationEnabled_;
|
||||||
|
@ -99,7 +99,7 @@ public:
|
||||||
startupIdleTime_ = startupIdleTime;
|
startupIdleTime_ = startupIdleTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLowestDownloadSpeedLimit(unsigned int lowestDownloadSpeedLimit)
|
void setLowestDownloadSpeedLimit(int lowestDownloadSpeedLimit)
|
||||||
{
|
{
|
||||||
lowestDownloadSpeedLimit_ = lowestDownloadSpeedLimit;
|
lowestDownloadSpeedLimit_ = lowestDownloadSpeedLimit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ std::string FeedbackURISelector::selectFaster
|
||||||
// Use first 10 good URIs to introduce some randomness.
|
// Use first 10 good URIs to introduce some randomness.
|
||||||
const size_t NUM_URI = 10;
|
const size_t NUM_URI = 10;
|
||||||
// Ignore low speed server
|
// Ignore low speed server
|
||||||
const unsigned int SPEED_THRESHOLD = 20*1024;
|
const int SPEED_THRESHOLD = 20*1024;
|
||||||
std::vector<std::pair<SharedHandle<ServerStat>, std::string> > fastCands;
|
std::vector<std::pair<SharedHandle<ServerStat>, std::string> > fastCands;
|
||||||
std::vector<std::string> normCands;
|
std::vector<std::string> normCands;
|
||||||
for(std::deque<std::string>::const_iterator i = uris.begin(),
|
for(std::deque<std::string>::const_iterator i = uris.begin(),
|
||||||
|
|
|
@ -230,7 +230,7 @@ FileEntry::findFasterRequest
|
||||||
const SharedHandle<ServerStatMan>& serverStatMan)
|
const SharedHandle<ServerStatMan>& serverStatMan)
|
||||||
{
|
{
|
||||||
const int startupIdleTime = 10;
|
const int startupIdleTime = 10;
|
||||||
const unsigned int SPEED_THRESHOLD = 20*1024;
|
const int SPEED_THRESHOLD = 20*1024;
|
||||||
if(lastFasterReplace_.difference(global::wallclock()) < startupIdleTime) {
|
if(lastFasterReplace_.difference(global::wallclock()) < startupIdleTime) {
|
||||||
return SharedHandle<Request>();
|
return SharedHandle<Request>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,11 +235,11 @@ bool FtpConnection::sendPort(const SharedHandle<SocketCore>& serverSocket)
|
||||||
if(socketBuffer_.sendBufferIsEmpty()) {
|
if(socketBuffer_.sendBufferIsEmpty()) {
|
||||||
std::pair<std::string, uint16_t> addrinfo;
|
std::pair<std::string, uint16_t> addrinfo;
|
||||||
socket_->getAddrInfo(addrinfo);
|
socket_->getAddrInfo(addrinfo);
|
||||||
unsigned int ipaddr[4];
|
int ipaddr[4];
|
||||||
sscanf(addrinfo.first.c_str(), "%u.%u.%u.%u",
|
sscanf(addrinfo.first.c_str(), "%d.%d.%d.%d",
|
||||||
&ipaddr[0], &ipaddr[1], &ipaddr[2], &ipaddr[3]);
|
&ipaddr[0], &ipaddr[1], &ipaddr[2], &ipaddr[3]);
|
||||||
serverSocket->getAddrInfo(addrinfo);
|
serverSocket->getAddrInfo(addrinfo);
|
||||||
std::string request = fmt("PORT %u,%u,%u,%u,%u,%u\r\n",
|
std::string request = fmt("PORT %d,%d,%d,%d,%d,%d\r\n",
|
||||||
ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3],
|
ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3],
|
||||||
addrinfo.second/256, addrinfo.second%256);
|
addrinfo.second/256, addrinfo.second%256);
|
||||||
A2_LOG_INFO(fmt(MSG_SENDING_REQUEST,
|
A2_LOG_INFO(fmt(MSG_SENDING_REQUEST,
|
||||||
|
@ -280,16 +280,16 @@ bool FtpConnection::sendRetr()
|
||||||
return socketBuffer_.sendBufferIsEmpty();
|
return socketBuffer_.sendBufferIsEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int FtpConnection::getStatus(const std::string& response) const
|
int FtpConnection::getStatus(const std::string& response) const
|
||||||
{
|
{
|
||||||
unsigned int status;
|
int status;
|
||||||
// When the response is not like "%u %*s",
|
// When the response is not like "%d %*s",
|
||||||
// we return 0.
|
// we return 0.
|
||||||
if(response.find_first_not_of("0123456789") != 3
|
if(response.find_first_not_of("0123456789") != 3
|
||||||
|| !(response.find(" ") == 3 || response.find("-") == 3)) {
|
|| !(response.find(" ") == 3 || response.find("-") == 3)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(sscanf(response.c_str(), "%u %*s", &status) == 1) {
|
if(sscanf(response.c_str(), "%d %*s", &status) == 1) {
|
||||||
return status;
|
return status;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -300,8 +300,8 @@ unsigned int FtpConnection::getStatus(const std::string& response) const
|
||||||
// The length includes \r\n.
|
// The length includes \r\n.
|
||||||
// If the whole response has not been received, then returns std::string::npos.
|
// If the whole response has not been received, then returns std::string::npos.
|
||||||
std::string::size_type
|
std::string::size_type
|
||||||
FtpConnection::findEndOfResponse(unsigned int status,
|
FtpConnection::findEndOfResponse
|
||||||
const std::string& buf) const
|
(int status, const std::string& buf) const
|
||||||
{
|
{
|
||||||
if(buf.size() <= 4) {
|
if(buf.size() <= 4) {
|
||||||
return std::string::npos;
|
return std::string::npos;
|
||||||
|
@ -310,7 +310,7 @@ FtpConnection::findEndOfResponse(unsigned int status,
|
||||||
if(buf.at(3) == '-') {
|
if(buf.at(3) == '-') {
|
||||||
// multi line response
|
// multi line response
|
||||||
std::string::size_type p;
|
std::string::size_type p;
|
||||||
p = buf.find(fmt("\r\n%u ", status));
|
p = buf.find(fmt("\r\n%d ", status));
|
||||||
if(p == std::string::npos) {
|
if(p == std::string::npos) {
|
||||||
return std::string::npos;
|
return std::string::npos;
|
||||||
}
|
}
|
||||||
|
@ -331,8 +331,7 @@ FtpConnection::findEndOfResponse(unsigned int status,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FtpConnection::bulkReceiveResponse
|
bool FtpConnection::bulkReceiveResponse(std::pair<int, std::string>& response)
|
||||||
(std::pair<unsigned int, std::string>& response)
|
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
while(1) {
|
while(1) {
|
||||||
|
@ -352,7 +351,7 @@ bool FtpConnection::bulkReceiveResponse
|
||||||
}
|
}
|
||||||
strbuf_.append(&buf[0], &buf[size]);
|
strbuf_.append(&buf[0], &buf[size]);
|
||||||
}
|
}
|
||||||
unsigned int status;
|
int status;
|
||||||
if(strbuf_.size() >= 4) {
|
if(strbuf_.size() >= 4) {
|
||||||
status = getStatus(strbuf_);
|
status = getStatus(strbuf_);
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
|
@ -377,9 +376,9 @@ bool FtpConnection::bulkReceiveResponse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int FtpConnection::receiveResponse()
|
int FtpConnection::receiveResponse()
|
||||||
{
|
{
|
||||||
std::pair<unsigned int, std::string> response;
|
std::pair<int, std::string> response;
|
||||||
if(bulkReceiveResponse(response)) {
|
if(bulkReceiveResponse(response)) {
|
||||||
return response.first;
|
return response.first;
|
||||||
} else {
|
} else {
|
||||||
|
@ -400,9 +399,9 @@ unsigned int FtpConnection::receiveResponse()
|
||||||
# define ULONGLONG_SCANF "%Lu"
|
# define ULONGLONG_SCANF "%Lu"
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
|
||||||
unsigned int FtpConnection::receiveSizeResponse(off_t& size)
|
int FtpConnection::receiveSizeResponse(off_t& size)
|
||||||
{
|
{
|
||||||
std::pair<unsigned int, std::string> response;
|
std::pair<int, std::string> response;
|
||||||
if(bulkReceiveResponse(response)) {
|
if(bulkReceiveResponse(response)) {
|
||||||
if(response.first == 213) {
|
if(response.first == 213) {
|
||||||
std::pair<Sip, Sip> rp;
|
std::pair<Sip, Sip> rp;
|
||||||
|
@ -418,10 +417,10 @@ unsigned int FtpConnection::receiveSizeResponse(off_t& size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int FtpConnection::receiveMdtmResponse(Time& time)
|
int FtpConnection::receiveMdtmResponse(Time& time)
|
||||||
{
|
{
|
||||||
// MDTM command, specified in RFC3659.
|
// MDTM command, specified in RFC3659.
|
||||||
std::pair<unsigned int, std::string> response;
|
std::pair<int, std::string> response;
|
||||||
if(bulkReceiveResponse(response)) {
|
if(bulkReceiveResponse(response)) {
|
||||||
if(response.first == 213) {
|
if(response.first == 213) {
|
||||||
char buf[15]; // YYYYMMDDhhmmss+\0, milli second part is dropped.
|
char buf[15]; // YYYYMMDDhhmmss+\0, milli second part is dropped.
|
||||||
|
@ -448,9 +447,9 @@ unsigned int FtpConnection::receiveMdtmResponse(Time& time)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int FtpConnection::receiveEpsvResponse(uint16_t& port)
|
int FtpConnection::receiveEpsvResponse(uint16_t& port)
|
||||||
{
|
{
|
||||||
std::pair<unsigned int, std::string> response;
|
std::pair<int, std::string> response;
|
||||||
if(bulkReceiveResponse(response)) {
|
if(bulkReceiveResponse(response)) {
|
||||||
if(response.first == 229) {
|
if(response.first == 229) {
|
||||||
port = 0;
|
port = 0;
|
||||||
|
@ -479,22 +478,22 @@ unsigned int FtpConnection::receiveEpsvResponse(uint16_t& port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int FtpConnection::receivePasvResponse
|
int FtpConnection::receivePasvResponse
|
||||||
(std::pair<std::string, uint16_t>& dest)
|
(std::pair<std::string, uint16_t>& dest)
|
||||||
{
|
{
|
||||||
std::pair<unsigned int, std::string> response;
|
std::pair<int, std::string> response;
|
||||||
if(bulkReceiveResponse(response)) {
|
if(bulkReceiveResponse(response)) {
|
||||||
if(response.first == 227) {
|
if(response.first == 227) {
|
||||||
// we assume the format of response is "227 Entering Passive
|
// we assume the format of response is "227 Entering Passive
|
||||||
// Mode (h1,h2,h3,h4,p1,p2)."
|
// Mode (h1,h2,h3,h4,p1,p2)."
|
||||||
unsigned int h1, h2, h3, h4, p1, p2;
|
int h1, h2, h3, h4, p1, p2;
|
||||||
std::string::size_type p = response.second.find("(");
|
std::string::size_type p = response.second.find("(");
|
||||||
if(p >= 4) {
|
if(p >= 4) {
|
||||||
sscanf(response.second.c_str()+p,
|
sscanf(response.second.c_str()+p,
|
||||||
"(%u,%u,%u,%u,%u,%u).",
|
"(%d,%d,%d,%d,%d,%d).",
|
||||||
&h1, &h2, &h3, &h4, &p1, &p2);
|
&h1, &h2, &h3, &h4, &p1, &p2);
|
||||||
// ip address
|
// ip address
|
||||||
dest.first = fmt("%u.%u.%u.%u", h1, h2, h3, h4);
|
dest.first = fmt("%d.%d.%d.%d", h1, h2, h3, h4);
|
||||||
// port number
|
// port number
|
||||||
dest.second = 256*p1+p2;
|
dest.second = 256*p1+p2;
|
||||||
} else {
|
} else {
|
||||||
|
@ -507,9 +506,9 @@ unsigned int FtpConnection::receivePasvResponse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int FtpConnection::receivePwdResponse(std::string& pwd)
|
int FtpConnection::receivePwdResponse(std::string& pwd)
|
||||||
{
|
{
|
||||||
std::pair<unsigned int, std::string> response;
|
std::pair<int, std::string> response;
|
||||||
if(bulkReceiveResponse(response)) {
|
if(bulkReceiveResponse(response)) {
|
||||||
if(response.first == 257) {
|
if(response.first == 257) {
|
||||||
std::string::size_type first;
|
std::string::size_type first;
|
||||||
|
|
|
@ -69,10 +69,10 @@ private:
|
||||||
|
|
||||||
std::string baseWorkingDir_;
|
std::string baseWorkingDir_;
|
||||||
|
|
||||||
unsigned int getStatus(const std::string& response) const;
|
int getStatus(const std::string& response) const;
|
||||||
std::string::size_type findEndOfResponse(unsigned int status,
|
std::string::size_type findEndOfResponse
|
||||||
const std::string& buf) const;
|
(int status, const std::string& buf) const;
|
||||||
bool bulkReceiveResponse(std::pair<unsigned int, std::string>& response);
|
bool bulkReceiveResponse(std::pair<int, std::string>& response);
|
||||||
|
|
||||||
static const std::string A;
|
static const std::string A;
|
||||||
|
|
||||||
|
@ -101,18 +101,18 @@ public:
|
||||||
bool sendRest(const SharedHandle<Segment>& segment);
|
bool sendRest(const SharedHandle<Segment>& segment);
|
||||||
bool sendRetr();
|
bool sendRetr();
|
||||||
|
|
||||||
unsigned int receiveResponse();
|
int receiveResponse();
|
||||||
unsigned int receiveSizeResponse(off_t& size);
|
int receiveSizeResponse(off_t& size);
|
||||||
// Returns status code of MDTM reply. If the status code is 213, parses
|
// Returns status code of MDTM reply. If the status code is 213, parses
|
||||||
// time-val and store it in time.
|
// time-val and store it in time.
|
||||||
// If a code other than 213 is returned, time is not touched.
|
// If a code other than 213 is returned, time is not touched.
|
||||||
// Expect MDTM reply is YYYYMMDDhhmmss in GMT. If status is 213 but returned
|
// Expect MDTM reply is YYYYMMDDhhmmss in GMT. If status is 213 but returned
|
||||||
// date cannot be parsed, then assign Time::null() to given time.
|
// date cannot be parsed, then assign Time::null() to given time.
|
||||||
// If reply is not received yet, returns 0.
|
// If reply is not received yet, returns 0.
|
||||||
unsigned int receiveMdtmResponse(Time& time);
|
int receiveMdtmResponse(Time& time);
|
||||||
unsigned int receiveEpsvResponse(uint16_t& port);
|
int receiveEpsvResponse(uint16_t& port);
|
||||||
unsigned int receivePasvResponse(std::pair<std::string, uint16_t>& dest);
|
int receivePasvResponse(std::pair<std::string, uint16_t>& dest);
|
||||||
unsigned int receivePwdResponse(std::string& pwd);
|
int receivePwdResponse(std::string& pwd);
|
||||||
|
|
||||||
void setBaseWorkingDir(const std::string& baseWorkingDir);
|
void setBaseWorkingDir(const std::string& baseWorkingDir);
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ bool FtpFinishDownloadCommand::execute()
|
||||||
try {
|
try {
|
||||||
if(readEventEnabled() || hupEventEnabled()) {
|
if(readEventEnabled() || hupEventEnabled()) {
|
||||||
getCheckPoint() = global::wallclock();
|
getCheckPoint() = global::wallclock();
|
||||||
unsigned int status = ftpConnection_->receiveResponse();
|
int status = ftpConnection_->receiveResponse();
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
getDownloadEngine()->addCommand(this);
|
getDownloadEngine()->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -153,7 +153,7 @@ bool FtpNegotiationCommand::recvGreeting() {
|
||||||
disableWriteCheckSocket();
|
disableWriteCheckSocket();
|
||||||
setReadCheckSocket(getSocket());
|
setReadCheckSocket(getSocket());
|
||||||
|
|
||||||
unsigned int status = ftp_->receiveResponse();
|
int status = ftp_->receiveResponse();
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ bool FtpNegotiationCommand::sendUser() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FtpNegotiationCommand::recvUser() {
|
bool FtpNegotiationCommand::recvUser() {
|
||||||
unsigned int status = ftp_->receiveResponse();
|
int status = ftp_->receiveResponse();
|
||||||
switch(status) {
|
switch(status) {
|
||||||
case 0:
|
case 0:
|
||||||
return false;
|
return false;
|
||||||
|
@ -204,7 +204,7 @@ bool FtpNegotiationCommand::sendPass() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FtpNegotiationCommand::recvPass() {
|
bool FtpNegotiationCommand::recvPass() {
|
||||||
unsigned int status = ftp_->receiveResponse();
|
int status = ftp_->receiveResponse();
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ bool FtpNegotiationCommand::sendType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FtpNegotiationCommand::recvType() {
|
bool FtpNegotiationCommand::recvType() {
|
||||||
unsigned int status = ftp_->receiveResponse();
|
int status = ftp_->receiveResponse();
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ bool FtpNegotiationCommand::sendPwd()
|
||||||
bool FtpNegotiationCommand::recvPwd()
|
bool FtpNegotiationCommand::recvPwd()
|
||||||
{
|
{
|
||||||
std::string pwd;
|
std::string pwd;
|
||||||
unsigned int status = ftp_->receivePwdResponse(pwd);
|
int status = ftp_->receivePwdResponse(pwd);
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ bool FtpNegotiationCommand::sendCwd()
|
||||||
|
|
||||||
bool FtpNegotiationCommand::recvCwd()
|
bool FtpNegotiationCommand::recvCwd()
|
||||||
{
|
{
|
||||||
unsigned int status = ftp_->receiveResponse();
|
int status = ftp_->receiveResponse();
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ bool FtpNegotiationCommand::sendMdtm()
|
||||||
bool FtpNegotiationCommand::recvMdtm()
|
bool FtpNegotiationCommand::recvMdtm()
|
||||||
{
|
{
|
||||||
Time lastModifiedTime = Time::null();
|
Time lastModifiedTime = Time::null();
|
||||||
unsigned int status = ftp_->receiveMdtmResponse(lastModifiedTime);
|
int status = ftp_->receiveMdtmResponse(lastModifiedTime);
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -465,7 +465,7 @@ bool FtpNegotiationCommand::onFileSizeDetermined(off_t totalLength)
|
||||||
|
|
||||||
bool FtpNegotiationCommand::recvSize() {
|
bool FtpNegotiationCommand::recvSize() {
|
||||||
off_t size = 0;
|
off_t size = 0;
|
||||||
unsigned int status = ftp_->receiveSizeResponse(size);
|
int status = ftp_->receiveSizeResponse(size);
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -546,7 +546,7 @@ bool FtpNegotiationCommand::sendEprt() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FtpNegotiationCommand::recvEprt() {
|
bool FtpNegotiationCommand::recvEprt() {
|
||||||
unsigned int status = ftp_->receiveResponse();
|
int status = ftp_->receiveResponse();
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -569,7 +569,7 @@ bool FtpNegotiationCommand::sendPort() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FtpNegotiationCommand::recvPort() {
|
bool FtpNegotiationCommand::recvPort() {
|
||||||
unsigned int status = ftp_->receiveResponse();
|
int status = ftp_->receiveResponse();
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -603,7 +603,7 @@ bool FtpNegotiationCommand::sendEpsv() {
|
||||||
|
|
||||||
bool FtpNegotiationCommand::recvEpsv() {
|
bool FtpNegotiationCommand::recvEpsv() {
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
unsigned int status = ftp_->receiveEpsvResponse(port);
|
int status = ftp_->receiveEpsvResponse(port);
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -628,7 +628,7 @@ bool FtpNegotiationCommand::sendPasv() {
|
||||||
|
|
||||||
bool FtpNegotiationCommand::recvPasv() {
|
bool FtpNegotiationCommand::recvPasv() {
|
||||||
std::pair<std::string, uint16_t> dest;
|
std::pair<std::string, uint16_t> dest;
|
||||||
unsigned int status = ftp_->receivePasvResponse(dest);
|
int status = ftp_->receivePasvResponse(dest);
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -781,7 +781,7 @@ bool FtpNegotiationCommand::sendRest(const SharedHandle<Segment>& segment) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FtpNegotiationCommand::recvRest(const SharedHandle<Segment>& segment) {
|
bool FtpNegotiationCommand::recvRest(const SharedHandle<Segment>& segment) {
|
||||||
unsigned int status = ftp_->receiveResponse();
|
int status = ftp_->receiveResponse();
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -808,7 +808,7 @@ bool FtpNegotiationCommand::sendRetr() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FtpNegotiationCommand::recvRetr() {
|
bool FtpNegotiationCommand::recvRetr() {
|
||||||
unsigned int status = ftp_->receiveResponse();
|
int status = ftp_->receiveResponse();
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ bool HttpSkipResponseCommand::processResponse()
|
||||||
{
|
{
|
||||||
int statusCode;
|
int statusCode;
|
||||||
if(httpResponse_->isRedirect()) {
|
if(httpResponse_->isRedirect()) {
|
||||||
unsigned int rnum =
|
int rnum =
|
||||||
httpResponse_->getHttpRequest()->getRequest()->getRedirectCount();
|
httpResponse_->getHttpRequest()->getRequest()->getRedirectCount();
|
||||||
if(rnum >= Request::MAX_REDIRECT) {
|
if(rnum >= Request::MAX_REDIRECT) {
|
||||||
throw DL_ABORT_EX2(fmt("Too many redirects: count=%u", rnum),
|
throw DL_ABORT_EX2(fmt("Too many redirects: count=%u", rnum),
|
||||||
|
|
|
@ -48,7 +48,7 @@ class LpdDispatchMessageCommand:public Command {
|
||||||
private:
|
private:
|
||||||
SharedHandle<LpdMessageDispatcher> dispatcher_;
|
SharedHandle<LpdMessageDispatcher> dispatcher_;
|
||||||
DownloadEngine* e_;
|
DownloadEngine* e_;
|
||||||
unsigned int tryCount_;
|
int tryCount_;
|
||||||
SharedHandle<BtRuntime> btRuntime_;
|
SharedHandle<BtRuntime> btRuntime_;
|
||||||
public:
|
public:
|
||||||
LpdDispatchMessageCommand
|
LpdDispatchMessageCommand
|
||||||
|
|
|
@ -216,13 +216,13 @@ void Peer::updateBitfield(size_t index, int operation) {
|
||||||
updateSeeder();
|
updateSeeder();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Peer::calculateUploadSpeed()
|
int Peer::calculateUploadSpeed()
|
||||||
{
|
{
|
||||||
assert(res_);
|
assert(res_);
|
||||||
return res_->getPeerStat().calculateUploadSpeed();
|
return res_->getPeerStat().calculateUploadSpeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Peer::calculateDownloadSpeed()
|
int Peer::calculateDownloadSpeed()
|
||||||
{
|
{
|
||||||
assert(res_);
|
assert(res_);
|
||||||
return res_->getPeerStat().calculateDownloadSpeed();
|
return res_->getPeerStat().calculateDownloadSpeed();
|
||||||
|
|
|
@ -224,12 +224,12 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns the transfer rate from localhost to remote host.
|
* Returns the transfer rate from localhost to remote host.
|
||||||
*/
|
*/
|
||||||
unsigned int calculateUploadSpeed();
|
int calculateUploadSpeed();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the transfer rate from remote host to localhost.
|
* Returns the transfer rate from remote host to localhost.
|
||||||
*/
|
*/
|
||||||
unsigned int calculateDownloadSpeed();
|
int calculateDownloadSpeed();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of bytes uploaded to the remote host.
|
* Returns the number of bytes uploaded to the remote host.
|
||||||
|
|
|
@ -127,9 +127,9 @@ bool PeerReceiveHandshakeCommand::executeInternal()
|
||||||
}
|
}
|
||||||
TransferStat tstat =
|
TransferStat tstat =
|
||||||
downloadContext->getOwnerRequestGroup()->calculateStat();
|
downloadContext->getOwnerRequestGroup()->calculateStat();
|
||||||
const unsigned int maxDownloadLimit =
|
const int maxDownloadLimit =
|
||||||
downloadContext->getOwnerRequestGroup()->getMaxDownloadSpeedLimit();
|
downloadContext->getOwnerRequestGroup()->getMaxDownloadSpeedLimit();
|
||||||
unsigned int thresholdSpeed =
|
int thresholdSpeed =
|
||||||
downloadContext->getOwnerRequestGroup()->
|
downloadContext->getOwnerRequestGroup()->
|
||||||
getOption()->getAsInt(PREF_BT_REQUEST_PEER_SPEED_LIMIT);
|
getOption()->getAsInt(PREF_BT_REQUEST_PEER_SPEED_LIMIT);
|
||||||
if(maxDownloadLimit > 0) {
|
if(maxDownloadLimit > 0) {
|
||||||
|
|
|
@ -65,23 +65,23 @@ PeerStat::~PeerStat() {}
|
||||||
/**
|
/**
|
||||||
* Returns current download speed in byte per sec.
|
* Returns current download speed in byte per sec.
|
||||||
*/
|
*/
|
||||||
unsigned int PeerStat::calculateDownloadSpeed()
|
int PeerStat::calculateDownloadSpeed()
|
||||||
{
|
{
|
||||||
return downloadSpeed_.calculateSpeed();
|
return downloadSpeed_.calculateSpeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int PeerStat::calculateAvgDownloadSpeed()
|
int PeerStat::calculateAvgDownloadSpeed()
|
||||||
{
|
{
|
||||||
avgDownloadSpeed_ = downloadSpeed_.calculateAvgSpeed();
|
avgDownloadSpeed_ = downloadSpeed_.calculateAvgSpeed();
|
||||||
return avgDownloadSpeed_;
|
return avgDownloadSpeed_;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int PeerStat::calculateUploadSpeed()
|
int PeerStat::calculateUploadSpeed()
|
||||||
{
|
{
|
||||||
return uploadSpeed_.calculateSpeed();
|
return uploadSpeed_.calculateSpeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int PeerStat::calculateAvgUploadSpeed()
|
int PeerStat::calculateAvgUploadSpeed()
|
||||||
{
|
{
|
||||||
avgUploadSpeed_ = uploadSpeed_.calculateAvgSpeed();
|
avgUploadSpeed_ = uploadSpeed_.calculateAvgSpeed();
|
||||||
return avgUploadSpeed_;
|
return avgUploadSpeed_;
|
||||||
|
@ -99,12 +99,12 @@ void PeerStat::updateUploadLength(size_t bytes)
|
||||||
sessionUploadLength_ += bytes;
|
sessionUploadLength_ += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int PeerStat::getMaxDownloadSpeed() const
|
int PeerStat::getMaxDownloadSpeed() const
|
||||||
{
|
{
|
||||||
return downloadSpeed_.getMaxSpeed();
|
return downloadSpeed_.getMaxSpeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int PeerStat::getMaxUploadSpeed() const
|
int PeerStat::getMaxUploadSpeed() const
|
||||||
{
|
{
|
||||||
return uploadSpeed_.getMaxSpeed();
|
return uploadSpeed_.getMaxSpeed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,8 @@ private:
|
||||||
SpeedCalc uploadSpeed_;
|
SpeedCalc uploadSpeed_;
|
||||||
Timer downloadStartTime_;
|
Timer downloadStartTime_;
|
||||||
PeerStat::STATUS status_;
|
PeerStat::STATUS status_;
|
||||||
unsigned int avgDownloadSpeed_;
|
int avgDownloadSpeed_;
|
||||||
unsigned int avgUploadSpeed_;
|
int avgUploadSpeed_;
|
||||||
int64_t sessionDownloadLength_;
|
int64_t sessionDownloadLength_;
|
||||||
int64_t sessionUploadLength_;
|
int64_t sessionUploadLength_;
|
||||||
public:
|
public:
|
||||||
|
@ -78,28 +78,28 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns current download speed in byte per sec.
|
* Returns current download speed in byte per sec.
|
||||||
*/
|
*/
|
||||||
unsigned int calculateDownloadSpeed();
|
int calculateDownloadSpeed();
|
||||||
|
|
||||||
unsigned int calculateAvgDownloadSpeed();
|
int calculateAvgDownloadSpeed();
|
||||||
|
|
||||||
unsigned int calculateUploadSpeed();
|
int calculateUploadSpeed();
|
||||||
|
|
||||||
unsigned int calculateAvgUploadSpeed();
|
int calculateAvgUploadSpeed();
|
||||||
|
|
||||||
void updateDownloadLength(size_t bytes);
|
void updateDownloadLength(size_t bytes);
|
||||||
|
|
||||||
void updateUploadLength(size_t bytes);
|
void updateUploadLength(size_t bytes);
|
||||||
|
|
||||||
unsigned int getMaxDownloadSpeed() const;
|
int getMaxDownloadSpeed() const;
|
||||||
|
|
||||||
unsigned int getMaxUploadSpeed() const;
|
int getMaxUploadSpeed() const;
|
||||||
|
|
||||||
unsigned int getAvgDownloadSpeed() const
|
int getAvgDownloadSpeed() const
|
||||||
{
|
{
|
||||||
return avgDownloadSpeed_;
|
return avgDownloadSpeed_;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getAvgUploadSpeed() const
|
int getAvgUploadSpeed() const
|
||||||
{
|
{
|
||||||
return avgUploadSpeed_;
|
return avgUploadSpeed_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ void Request::resetRedirectCount()
|
||||||
redirectCount_ = 0;
|
redirectCount_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Request::setMaxPipelinedRequest(unsigned int num)
|
void Request::setMaxPipelinedRequest(int num)
|
||||||
{
|
{
|
||||||
maxPipelinedRequest_ = num;
|
maxPipelinedRequest_ = num;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,8 +63,8 @@ private:
|
||||||
std::string connectedHostname_;
|
std::string connectedHostname_;
|
||||||
std::string connectedAddr_;
|
std::string connectedAddr_;
|
||||||
|
|
||||||
unsigned int tryCount_;
|
int tryCount_;
|
||||||
unsigned int redirectCount_;
|
int redirectCount_;
|
||||||
// whether or not the server supports persistent connection
|
// whether or not the server supports persistent connection
|
||||||
bool supportsPersistentConnection_;
|
bool supportsPersistentConnection_;
|
||||||
// enable keep-alive if possible.
|
// enable keep-alive if possible.
|
||||||
|
@ -72,7 +72,7 @@ private:
|
||||||
// enable pipelining if possible.
|
// enable pipelining if possible.
|
||||||
bool pipeliningHint_;
|
bool pipeliningHint_;
|
||||||
// maximum number of pipelined requests
|
// maximum number of pipelined requests
|
||||||
unsigned int maxPipelinedRequest_;
|
int maxPipelinedRequest_;
|
||||||
SharedHandle<PeerStat> peerStat_;
|
SharedHandle<PeerStat> peerStat_;
|
||||||
bool removalRequested_;
|
bool removalRequested_;
|
||||||
uint16_t connectedPort_;
|
uint16_t connectedPort_;
|
||||||
|
@ -91,9 +91,9 @@ public:
|
||||||
bool resetUri();
|
bool resetUri();
|
||||||
void resetTryCount() { tryCount_ = 0; }
|
void resetTryCount() { tryCount_ = 0; }
|
||||||
void addTryCount() { ++tryCount_; }
|
void addTryCount() { ++tryCount_; }
|
||||||
unsigned int getTryCount() const { return tryCount_; }
|
int getTryCount() const { return tryCount_; }
|
||||||
void resetRedirectCount();
|
void resetRedirectCount();
|
||||||
unsigned int getRedirectCount() const { return redirectCount_; }
|
int getRedirectCount() const { return redirectCount_; }
|
||||||
// Returns URI passed by setUri()
|
// Returns URI passed by setUri()
|
||||||
const std::string& getUri() const { return uri_; }
|
const std::string& getUri() const { return uri_; }
|
||||||
const std::string& getCurrentUri() const { return currentUri_; }
|
const std::string& getCurrentUri() const { return currentUri_; }
|
||||||
|
@ -146,9 +146,9 @@ public:
|
||||||
return pipeliningHint_;
|
return pipeliningHint_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMaxPipelinedRequest(unsigned int num);
|
void setMaxPipelinedRequest(int num);
|
||||||
|
|
||||||
unsigned int getMaxPipelinedRequest() const
|
int getMaxPipelinedRequest() const
|
||||||
{
|
{
|
||||||
return maxPipelinedRequest_;
|
return maxPipelinedRequest_;
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ public:
|
||||||
|
|
||||||
static const std::string PROTO_FTP;
|
static const std::string PROTO_FTP;
|
||||||
|
|
||||||
static const unsigned int MAX_REDIRECT = 20;
|
static const int MAX_REDIRECT = 20;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -788,8 +788,8 @@ bool RequestGroup::tryAutoFileRenaming()
|
||||||
if(filepath.empty()) {
|
if(filepath.empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(unsigned int i = 1; i < 10000; ++i) {
|
for(int i = 1; i < 10000; ++i) {
|
||||||
std::string newfilename = fmt("%s.%u", filepath.c_str(), i);
|
std::string newfilename = fmt("%s.%d", filepath.c_str(), i);
|
||||||
File newfile(newfilename);
|
File newfile(newfilename);
|
||||||
File ctrlfile(newfile.getPath()+DefaultBtProgressInfoFile::getSuffix());
|
File ctrlfile(newfile.getPath()+DefaultBtProgressInfoFile::getSuffix());
|
||||||
if(!newfile.exists() || (newfile.exists() && ctrlfile.exists())) {
|
if(!newfile.exists() || (newfile.exists() && ctrlfile.exists())) {
|
||||||
|
@ -808,7 +808,7 @@ void RequestGroup::createNextCommandWithAdj(std::vector<Command*>& commands,
|
||||||
numCommand = 1+numAdj;
|
numCommand = 1+numAdj;
|
||||||
} else {
|
} else {
|
||||||
numCommand = std::min(downloadContext_->getNumPieces(),
|
numCommand = std::min(downloadContext_->getNumPieces(),
|
||||||
numConcurrentCommand_);
|
static_cast<size_t>(numConcurrentCommand_));
|
||||||
numCommand += numAdj;
|
numCommand += numAdj;
|
||||||
}
|
}
|
||||||
if(numCommand > 0) {
|
if(numCommand > 0) {
|
||||||
|
@ -830,8 +830,9 @@ void RequestGroup::createNextCommand(std::vector<Command*>& commands,
|
||||||
if(numStreamCommand_ >= numConcurrentCommand_) {
|
if(numStreamCommand_ >= numConcurrentCommand_) {
|
||||||
numCommand = 0;
|
numCommand = 0;
|
||||||
} else {
|
} else {
|
||||||
numCommand = std::min(downloadContext_->getNumPieces(),
|
numCommand =
|
||||||
numConcurrentCommand_-numStreamCommand_);
|
std::min(downloadContext_->getNumPieces(),
|
||||||
|
static_cast<size_t>(numConcurrentCommand_-numStreamCommand_));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(numCommand > 0) {
|
if(numCommand > 0) {
|
||||||
|
@ -841,9 +842,9 @@ void RequestGroup::createNextCommand(std::vector<Command*>& commands,
|
||||||
|
|
||||||
void RequestGroup::createNextCommand(std::vector<Command*>& commands,
|
void RequestGroup::createNextCommand(std::vector<Command*>& commands,
|
||||||
DownloadEngine* e,
|
DownloadEngine* e,
|
||||||
unsigned int numCommand)
|
int numCommand)
|
||||||
{
|
{
|
||||||
for(; numCommand--; ) {
|
for(; numCommand > 0; --numCommand) {
|
||||||
Command* command = new CreateRequestCommand(e->newCUID(), this, e);
|
Command* command = new CreateRequestCommand(e->newCUID(), this, e);
|
||||||
commands.push_back(command);
|
commands.push_back(command);
|
||||||
}
|
}
|
||||||
|
@ -946,9 +947,9 @@ void RequestGroup::decreaseStreamConnection()
|
||||||
--numStreamConnection_;
|
--numStreamConnection_;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int RequestGroup::getNumConnection() const
|
int RequestGroup::getNumConnection() const
|
||||||
{
|
{
|
||||||
unsigned int numConnection = numStreamConnection_;
|
int numConnection = numStreamConnection_;
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
if(btRuntime_) {
|
if(btRuntime_) {
|
||||||
numConnection += btRuntime_->getConnections();
|
numConnection += btRuntime_->getConnections();
|
||||||
|
@ -1259,12 +1260,12 @@ void RequestGroup::updateLastModifiedTime(const Time& time)
|
||||||
void RequestGroup::increaseAndValidateFileNotFoundCount()
|
void RequestGroup::increaseAndValidateFileNotFoundCount()
|
||||||
{
|
{
|
||||||
++fileNotFoundCount_;
|
++fileNotFoundCount_;
|
||||||
const unsigned int maxCount = option_->getAsInt(PREF_MAX_FILE_NOT_FOUND);
|
const int maxCount = option_->getAsInt(PREF_MAX_FILE_NOT_FOUND);
|
||||||
if(maxCount > 0 && fileNotFoundCount_ >= maxCount &&
|
if(maxCount > 0 && fileNotFoundCount_ >= maxCount &&
|
||||||
(!segmentMan_ ||
|
(!segmentMan_ ||
|
||||||
segmentMan_->calculateSessionDownloadLength() == 0)) {
|
segmentMan_->calculateSessionDownloadLength() == 0)) {
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION2
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
||||||
(fmt("Reached max-file-not-found count=%u", maxCount),
|
(fmt("Reached max-file-not-found count=%d", maxCount),
|
||||||
error_code::MAX_FILE_NOT_FOUND);
|
error_code::MAX_FILE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,16 +90,16 @@ private:
|
||||||
|
|
||||||
SharedHandle<Option> option_;
|
SharedHandle<Option> option_;
|
||||||
|
|
||||||
size_t numConcurrentCommand_;
|
int numConcurrentCommand_;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the number of connections used in streaming protocol(http/ftp)
|
* This is the number of connections used in streaming protocol(http/ftp)
|
||||||
*/
|
*/
|
||||||
unsigned int numStreamConnection_;
|
int numStreamConnection_;
|
||||||
|
|
||||||
unsigned int numStreamCommand_;
|
int numStreamCommand_;
|
||||||
|
|
||||||
unsigned int numCommand_;
|
int numCommand_;
|
||||||
|
|
||||||
SharedHandle<SegmentMan> segmentMan_;
|
SharedHandle<SegmentMan> segmentMan_;
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ private:
|
||||||
|
|
||||||
Time lastModifiedTime_;
|
Time lastModifiedTime_;
|
||||||
|
|
||||||
unsigned int fileNotFoundCount_;
|
int fileNotFoundCount_;
|
||||||
|
|
||||||
// Timeout used for HTTP/FTP downloads.
|
// Timeout used for HTTP/FTP downloads.
|
||||||
time_t timeout_;
|
time_t timeout_;
|
||||||
|
@ -152,9 +152,9 @@ private:
|
||||||
// just sits in memory.
|
// just sits in memory.
|
||||||
bool inMemoryDownload_;
|
bool inMemoryDownload_;
|
||||||
|
|
||||||
unsigned int maxDownloadSpeedLimit_;
|
int maxDownloadSpeedLimit_;
|
||||||
|
|
||||||
unsigned int maxUploadSpeedLimit_;
|
int maxUploadSpeedLimit_;
|
||||||
|
|
||||||
error_code::Value lastErrorCode_;
|
error_code::Value lastErrorCode_;
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ public:
|
||||||
DownloadEngine* e, int numAdj);
|
DownloadEngine* e, int numAdj);
|
||||||
|
|
||||||
void createNextCommand(std::vector<Command*>& commands,
|
void createNextCommand(std::vector<Command*>& commands,
|
||||||
DownloadEngine* e, unsigned int numCommand);
|
DownloadEngine* e, int numCommand);
|
||||||
|
|
||||||
void createNextCommand(std::vector<Command*>& commands, DownloadEngine* e);
|
void createNextCommand(std::vector<Command*>& commands, DownloadEngine* e);
|
||||||
|
|
||||||
|
@ -246,12 +246,12 @@ public:
|
||||||
|
|
||||||
void validateTotalLength(off_t actualTotalLength) const;
|
void validateTotalLength(off_t actualTotalLength) const;
|
||||||
|
|
||||||
void setNumConcurrentCommand(unsigned int num)
|
void setNumConcurrentCommand(int num)
|
||||||
{
|
{
|
||||||
numConcurrentCommand_ = num;
|
numConcurrentCommand_ = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getNumConcurrentCommand() const
|
int getNumConcurrentCommand() const
|
||||||
{
|
{
|
||||||
return numConcurrentCommand_;
|
return numConcurrentCommand_;
|
||||||
}
|
}
|
||||||
|
@ -289,13 +289,13 @@ public:
|
||||||
|
|
||||||
void decreaseStreamConnection();
|
void decreaseStreamConnection();
|
||||||
|
|
||||||
unsigned int getNumConnection() const;
|
int getNumConnection() const;
|
||||||
|
|
||||||
void increaseNumCommand();
|
void increaseNumCommand();
|
||||||
|
|
||||||
void decreaseNumCommand();
|
void decreaseNumCommand();
|
||||||
|
|
||||||
unsigned int getNumCommand() const
|
int getNumCommand() const
|
||||||
{
|
{
|
||||||
return numCommand_;
|
return numCommand_;
|
||||||
}
|
}
|
||||||
|
@ -461,22 +461,22 @@ public:
|
||||||
// maxUploadSpeedLimit_ == 0. Otherwise returns false.
|
// maxUploadSpeedLimit_ == 0. Otherwise returns false.
|
||||||
bool doesUploadSpeedExceed();
|
bool doesUploadSpeedExceed();
|
||||||
|
|
||||||
unsigned int getMaxDownloadSpeedLimit() const
|
int getMaxDownloadSpeedLimit() const
|
||||||
{
|
{
|
||||||
return maxDownloadSpeedLimit_;
|
return maxDownloadSpeedLimit_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMaxDownloadSpeedLimit(unsigned int speed)
|
void setMaxDownloadSpeedLimit(int speed)
|
||||||
{
|
{
|
||||||
maxDownloadSpeedLimit_ = speed;
|
maxDownloadSpeedLimit_ = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getMaxUploadSpeedLimit() const
|
int getMaxUploadSpeedLimit() const
|
||||||
{
|
{
|
||||||
return maxUploadSpeedLimit_;
|
return maxUploadSpeedLimit_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMaxUploadSpeedLimit(unsigned int speed)
|
void setMaxUploadSpeedLimit(int speed)
|
||||||
{
|
{
|
||||||
maxUploadSpeedLimit_ = speed;
|
maxUploadSpeedLimit_ = speed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace aria2 {
|
||||||
|
|
||||||
RequestGroupMan::RequestGroupMan
|
RequestGroupMan::RequestGroupMan
|
||||||
(const std::vector<SharedHandle<RequestGroup> >& requestGroups,
|
(const std::vector<SharedHandle<RequestGroup> >& requestGroups,
|
||||||
unsigned int maxSimultaneousDownloads,
|
int maxSimultaneousDownloads,
|
||||||
const Option* option)
|
const Option* option)
|
||||||
: reservedGroups_(requestGroups.begin(), requestGroups.end()),
|
: reservedGroups_(requestGroups.begin(), requestGroups.end()),
|
||||||
maxSimultaneousDownloads_(maxSimultaneousDownloads),
|
maxSimultaneousDownloads_(maxSimultaneousDownloads),
|
||||||
|
@ -479,12 +479,12 @@ void createInitialCommand(const SharedHandle<RequestGroup>& requestGroup,
|
||||||
void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
|
void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
|
||||||
{
|
{
|
||||||
removeStoppedGroup(e);
|
removeStoppedGroup(e);
|
||||||
if(maxSimultaneousDownloads_ <= requestGroups_.size()) {
|
if(static_cast<size_t>(maxSimultaneousDownloads_) <= requestGroups_.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::vector<SharedHandle<RequestGroup> > temp;
|
std::vector<SharedHandle<RequestGroup> > temp;
|
||||||
unsigned int count = 0;
|
int count = 0;
|
||||||
size_t num = maxSimultaneousDownloads_-requestGroups_.size();
|
int num = maxSimultaneousDownloads_-requestGroups_.size();
|
||||||
while(count < num && !reservedGroups_.empty()) {
|
while(count < num && !reservedGroups_.empty()) {
|
||||||
SharedHandle<RequestGroup> groupToAdd = reservedGroups_.front();
|
SharedHandle<RequestGroup> groupToAdd = reservedGroups_.front();
|
||||||
reservedGroups_.pop_front();
|
reservedGroups_.pop_front();
|
||||||
|
|
|
@ -61,15 +61,15 @@ private:
|
||||||
std::deque<SharedHandle<RequestGroup> > requestGroups_;
|
std::deque<SharedHandle<RequestGroup> > requestGroups_;
|
||||||
std::deque<SharedHandle<RequestGroup> > reservedGroups_;
|
std::deque<SharedHandle<RequestGroup> > reservedGroups_;
|
||||||
std::deque<SharedHandle<DownloadResult> > downloadResults_;
|
std::deque<SharedHandle<DownloadResult> > downloadResults_;
|
||||||
unsigned int maxSimultaneousDownloads_;
|
int maxSimultaneousDownloads_;
|
||||||
|
|
||||||
const Option* option_;
|
const Option* option_;
|
||||||
|
|
||||||
SharedHandle<ServerStatMan> serverStatMan_;
|
SharedHandle<ServerStatMan> serverStatMan_;
|
||||||
|
|
||||||
unsigned int maxOverallDownloadSpeedLimit_;
|
int maxOverallDownloadSpeedLimit_;
|
||||||
|
|
||||||
unsigned int maxOverallUploadSpeedLimit_;
|
int maxOverallUploadSpeedLimit_;
|
||||||
|
|
||||||
// true if JSON-RPC/XML-RPC is enabled.
|
// true if JSON-RPC/XML-RPC is enabled.
|
||||||
bool rpc_;
|
bool rpc_;
|
||||||
|
@ -98,7 +98,7 @@ private:
|
||||||
(const SharedHandle<RequestGroup>& requestGroup) const;
|
(const SharedHandle<RequestGroup>& requestGroup) const;
|
||||||
public:
|
public:
|
||||||
RequestGroupMan(const std::vector<SharedHandle<RequestGroup> >& requestGroups,
|
RequestGroupMan(const std::vector<SharedHandle<RequestGroup> >& requestGroups,
|
||||||
unsigned int maxSimultaneousDownloads,
|
int maxSimultaneousDownloads,
|
||||||
const Option* option);
|
const Option* option);
|
||||||
|
|
||||||
~RequestGroupMan();
|
~RequestGroupMan();
|
||||||
|
@ -249,12 +249,12 @@ public:
|
||||||
// maxOverallDownloadSpeedLimit_ == 0. Otherwise returns false.
|
// maxOverallDownloadSpeedLimit_ == 0. Otherwise returns false.
|
||||||
bool doesOverallDownloadSpeedExceed();
|
bool doesOverallDownloadSpeedExceed();
|
||||||
|
|
||||||
void setMaxOverallDownloadSpeedLimit(unsigned int speed)
|
void setMaxOverallDownloadSpeedLimit(int speed)
|
||||||
{
|
{
|
||||||
maxOverallDownloadSpeedLimit_ = speed;
|
maxOverallDownloadSpeedLimit_ = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getMaxOverallDownloadSpeedLimit() const
|
int getMaxOverallDownloadSpeedLimit() const
|
||||||
{
|
{
|
||||||
return maxOverallDownloadSpeedLimit_;
|
return maxOverallDownloadSpeedLimit_;
|
||||||
}
|
}
|
||||||
|
@ -264,17 +264,17 @@ public:
|
||||||
// maxOverallUploadSpeedLimit_ == 0. Otherwise returns false.
|
// maxOverallUploadSpeedLimit_ == 0. Otherwise returns false.
|
||||||
bool doesOverallUploadSpeedExceed();
|
bool doesOverallUploadSpeedExceed();
|
||||||
|
|
||||||
void setMaxOverallUploadSpeedLimit(unsigned int speed)
|
void setMaxOverallUploadSpeedLimit(int speed)
|
||||||
{
|
{
|
||||||
maxOverallUploadSpeedLimit_ = speed;
|
maxOverallUploadSpeedLimit_ = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getMaxOverallUploadSpeedLimit() const
|
int getMaxOverallUploadSpeedLimit() const
|
||||||
{
|
{
|
||||||
return maxOverallUploadSpeedLimit_;
|
return maxOverallUploadSpeedLimit_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMaxSimultaneousDownloads(unsigned int max)
|
void setMaxSimultaneousDownloads(int max)
|
||||||
{
|
{
|
||||||
maxSimultaneousDownloads_ = max;
|
maxSimultaneousDownloads_ = max;
|
||||||
}
|
}
|
||||||
|
|
|
@ -404,9 +404,9 @@ void SegmentMan::updateFastestPeerStat(const SharedHandle<PeerStat>& peerStat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int SegmentMan::calculateDownloadSpeed()
|
int SegmentMan::calculateDownloadSpeed()
|
||||||
{
|
{
|
||||||
unsigned int speed = 0;
|
int speed = 0;
|
||||||
if(lastPeerStatDlspdMapUpdated_.differenceInMillis(global::wallclock())+
|
if(lastPeerStatDlspdMapUpdated_.differenceInMillis(global::wallclock())+
|
||||||
A2_DELTA_MILLIS >= 250){
|
A2_DELTA_MILLIS >= 250){
|
||||||
lastPeerStatDlspdMapUpdated_ = global::wallclock();
|
lastPeerStatDlspdMapUpdated_ = global::wallclock();
|
||||||
|
@ -414,7 +414,7 @@ unsigned int SegmentMan::calculateDownloadSpeed()
|
||||||
for(std::vector<SharedHandle<PeerStat> >::const_iterator i =
|
for(std::vector<SharedHandle<PeerStat> >::const_iterator i =
|
||||||
peerStats_.begin(), eoi = peerStats_.end(); i != eoi; ++i) {
|
peerStats_.begin(), eoi = peerStats_.end(); i != eoi; ++i) {
|
||||||
if((*i)->getStatus() == PeerStat::ACTIVE) {
|
if((*i)->getStatus() == PeerStat::ACTIVE) {
|
||||||
unsigned int s = (*i)->calculateDownloadSpeed();
|
int s = (*i)->calculateDownloadSpeed();
|
||||||
peerStatDlspdMap_[(*i)->getCuid()] = s;
|
peerStatDlspdMap_[(*i)->getCuid()] = s;
|
||||||
speed += s;
|
speed += s;
|
||||||
}
|
}
|
||||||
|
@ -428,8 +428,8 @@ unsigned int SegmentMan::calculateDownloadSpeed()
|
||||||
|
|
||||||
void SegmentMan::updateDownloadSpeedFor(const SharedHandle<PeerStat>& pstat)
|
void SegmentMan::updateDownloadSpeedFor(const SharedHandle<PeerStat>& pstat)
|
||||||
{
|
{
|
||||||
unsigned int newspd = pstat->calculateDownloadSpeed();
|
int newspd = pstat->calculateDownloadSpeed();
|
||||||
unsigned int oldSpd = peerStatDlspdMap_[pstat->getCuid()];
|
int oldSpd = peerStatDlspdMap_[pstat->getCuid()];
|
||||||
if(cachedDlspd_ > oldSpd) {
|
if(cachedDlspd_ > oldSpd) {
|
||||||
cachedDlspd_ -= oldSpd;
|
cachedDlspd_ -= oldSpd;
|
||||||
cachedDlspd_ += newspd;
|
cachedDlspd_ += newspd;
|
||||||
|
|
|
@ -95,11 +95,11 @@ private:
|
||||||
std::vector<SharedHandle<PeerStat> > fastestPeerStats_;
|
std::vector<SharedHandle<PeerStat> > fastestPeerStats_;
|
||||||
|
|
||||||
// key: PeerStat's cuid, value: its download speed
|
// key: PeerStat's cuid, value: its download speed
|
||||||
std::map<cuid_t, unsigned int> peerStatDlspdMap_;
|
std::map<cuid_t, int> peerStatDlspdMap_;
|
||||||
|
|
||||||
Timer lastPeerStatDlspdMapUpdated_;
|
Timer lastPeerStatDlspdMapUpdated_;
|
||||||
|
|
||||||
unsigned int cachedDlspd_;
|
int cachedDlspd_;
|
||||||
|
|
||||||
BitfieldMan ignoreBitfield_;
|
BitfieldMan ignoreBitfield_;
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns current download speed in bytes per sec.
|
* Returns current download speed in bytes per sec.
|
||||||
*/
|
*/
|
||||||
unsigned int calculateDownloadSpeed();
|
int calculateDownloadSpeed();
|
||||||
|
|
||||||
void updateDownloadSpeedFor(const SharedHandle<PeerStat>& pstat);
|
void updateDownloadSpeedFor(const SharedHandle<PeerStat>& pstat);
|
||||||
|
|
||||||
|
|
|
@ -68,12 +68,12 @@ void ServerStat::setLastUpdated(const Time& time)
|
||||||
lastUpdated_ = time;
|
lastUpdated_ = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStat::setDownloadSpeed(unsigned int downloadSpeed)
|
void ServerStat::setDownloadSpeed(int downloadSpeed)
|
||||||
{
|
{
|
||||||
downloadSpeed_ = downloadSpeed;
|
downloadSpeed_ = downloadSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStat::updateDownloadSpeed(unsigned int downloadSpeed)
|
void ServerStat::updateDownloadSpeed(int downloadSpeed)
|
||||||
{
|
{
|
||||||
downloadSpeed_ = downloadSpeed;
|
downloadSpeed_ = downloadSpeed;
|
||||||
if(downloadSpeed > 0) {
|
if(downloadSpeed > 0) {
|
||||||
|
@ -82,13 +82,12 @@ void ServerStat::updateDownloadSpeed(unsigned int downloadSpeed)
|
||||||
lastUpdated_.reset();
|
lastUpdated_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStat::setSingleConnectionAvgSpeed
|
void ServerStat::setSingleConnectionAvgSpeed(int singleConnectionAvgSpeed)
|
||||||
(unsigned int singleConnectionAvgSpeed)
|
|
||||||
{
|
{
|
||||||
singleConnectionAvgSpeed_ = singleConnectionAvgSpeed;
|
singleConnectionAvgSpeed_ = singleConnectionAvgSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStat::updateSingleConnectionAvgSpeed(unsigned int downloadSpeed)
|
void ServerStat::updateSingleConnectionAvgSpeed(int downloadSpeed)
|
||||||
{
|
{
|
||||||
float avgDownloadSpeed;
|
float avgDownloadSpeed;
|
||||||
if(counter_ == 0)
|
if(counter_ == 0)
|
||||||
|
@ -117,13 +116,12 @@ void ServerStat::updateSingleConnectionAvgSpeed(unsigned int downloadSpeed)
|
||||||
singleConnectionAvgSpeed_ = (int)avgDownloadSpeed;
|
singleConnectionAvgSpeed_ = (int)avgDownloadSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStat::setMultiConnectionAvgSpeed
|
void ServerStat::setMultiConnectionAvgSpeed(int multiConnectionAvgSpeed)
|
||||||
(unsigned int multiConnectionAvgSpeed)
|
|
||||||
{
|
{
|
||||||
multiConnectionAvgSpeed_ = multiConnectionAvgSpeed;
|
multiConnectionAvgSpeed_ = multiConnectionAvgSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStat::updateMultiConnectionAvgSpeed(unsigned int downloadSpeed)
|
void ServerStat::updateMultiConnectionAvgSpeed(int downloadSpeed)
|
||||||
{
|
{
|
||||||
float avgDownloadSpeed;
|
float avgDownloadSpeed;
|
||||||
if(counter_ == 0)
|
if(counter_ == 0)
|
||||||
|
@ -151,7 +149,7 @@ void ServerStat::increaseCounter()
|
||||||
++counter_;
|
++counter_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStat::setCounter(unsigned int value)
|
void ServerStat::setCounter(int value)
|
||||||
{
|
{
|
||||||
counter_ = value;
|
counter_ = value;
|
||||||
}
|
}
|
||||||
|
@ -208,8 +206,8 @@ bool ServerStat::operator==(const ServerStat& serverStat) const
|
||||||
|
|
||||||
std::string ServerStat::toString() const
|
std::string ServerStat::toString() const
|
||||||
{
|
{
|
||||||
return fmt("host=%s, protocol=%s, dl_speed=%u, sc_avg_speed=%u,"
|
return fmt("host=%s, protocol=%s, dl_speed=%d, sc_avg_speed=%d,"
|
||||||
" mc_avg_speed=%u, last_updated=%ld, counter=%u, status=%s",
|
" mc_avg_speed=%d, last_updated=%ld, counter=%d, status=%s",
|
||||||
getHostname().c_str(),
|
getHostname().c_str(),
|
||||||
getProtocol().c_str(),
|
getProtocol().c_str(),
|
||||||
getDownloadSpeed(),
|
getDownloadSpeed(),
|
||||||
|
|
|
@ -79,40 +79,40 @@ public:
|
||||||
// This method doesn't update _lastUpdate.
|
// This method doesn't update _lastUpdate.
|
||||||
void setLastUpdated(const Time& time);
|
void setLastUpdated(const Time& time);
|
||||||
|
|
||||||
unsigned int getDownloadSpeed() const
|
int getDownloadSpeed() const
|
||||||
{
|
{
|
||||||
return downloadSpeed_;
|
return downloadSpeed_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update download speed and update lastUpdated_
|
// update download speed and update lastUpdated_
|
||||||
void updateDownloadSpeed(unsigned int downloadSpeed);
|
void updateDownloadSpeed(int downloadSpeed);
|
||||||
|
|
||||||
// set download speed. This method doesn't update _lastUpdate.
|
// set download speed. This method doesn't update _lastUpdate.
|
||||||
void setDownloadSpeed(unsigned int downloadSpeed);
|
void setDownloadSpeed(int downloadSpeed);
|
||||||
|
|
||||||
unsigned int getSingleConnectionAvgSpeed() const
|
int getSingleConnectionAvgSpeed() const
|
||||||
{
|
{
|
||||||
return singleConnectionAvgSpeed_;
|
return singleConnectionAvgSpeed_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateSingleConnectionAvgSpeed(unsigned int downloadSpeed);
|
void updateSingleConnectionAvgSpeed(int downloadSpeed);
|
||||||
void setSingleConnectionAvgSpeed(unsigned int singleConnectionAvgSpeed);
|
void setSingleConnectionAvgSpeed(int singleConnectionAvgSpeed);
|
||||||
|
|
||||||
unsigned int getMultiConnectionAvgSpeed() const
|
int getMultiConnectionAvgSpeed() const
|
||||||
{
|
{
|
||||||
return multiConnectionAvgSpeed_;
|
return multiConnectionAvgSpeed_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateMultiConnectionAvgSpeed(unsigned int downloadSpeed);
|
void updateMultiConnectionAvgSpeed(int downloadSpeed);
|
||||||
void setMultiConnectionAvgSpeed(unsigned int singleConnectionAvgSpeed);
|
void setMultiConnectionAvgSpeed(int singleConnectionAvgSpeed);
|
||||||
|
|
||||||
unsigned int getCounter() const
|
int getCounter() const
|
||||||
{
|
{
|
||||||
return counter_;
|
return counter_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void increaseCounter();
|
void increaseCounter();
|
||||||
void setCounter(unsigned int value);
|
void setCounter(int value);
|
||||||
|
|
||||||
// This method doesn't update _lastUpdate.
|
// This method doesn't update _lastUpdate.
|
||||||
void setStatus(STATUS status);
|
void setStatus(STATUS status);
|
||||||
|
@ -153,13 +153,13 @@ private:
|
||||||
|
|
||||||
std::string protocol_;
|
std::string protocol_;
|
||||||
|
|
||||||
unsigned int downloadSpeed_;
|
int downloadSpeed_;
|
||||||
|
|
||||||
unsigned int singleConnectionAvgSpeed_;
|
int singleConnectionAvgSpeed_;
|
||||||
|
|
||||||
unsigned int multiConnectionAvgSpeed_;
|
int multiConnectionAvgSpeed_;
|
||||||
|
|
||||||
unsigned int counter_;
|
int counter_;
|
||||||
|
|
||||||
STATUS status_;
|
STATUS status_;
|
||||||
|
|
||||||
|
|
|
@ -61,10 +61,10 @@ void SpeedCalc::reset() {
|
||||||
nextInterval_ = CHANGE_INTERVAL_SEC;
|
nextInterval_ = CHANGE_INTERVAL_SEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int SpeedCalc::calculateSpeed() {
|
int SpeedCalc::calculateSpeed() {
|
||||||
int64_t milliElapsed = cpArray_[sw_].differenceInMillis(global::wallclock());
|
int64_t milliElapsed = cpArray_[sw_].differenceInMillis(global::wallclock());
|
||||||
if(milliElapsed) {
|
if(milliElapsed) {
|
||||||
unsigned int speed = lengthArray_[sw_]*1000/milliElapsed;
|
int speed = lengthArray_[sw_]*1000/milliElapsed;
|
||||||
prevSpeed_ = speed;
|
prevSpeed_ = speed;
|
||||||
maxSpeed_ = std::max(speed, maxSpeed_);
|
maxSpeed_ = std::max(speed, maxSpeed_);
|
||||||
if(isIntervalOver(milliElapsed)) {
|
if(isIntervalOver(milliElapsed)) {
|
||||||
|
@ -102,12 +102,12 @@ void SpeedCalc::changeSw() {
|
||||||
cpArray_[sw_].difference(global::wallclock())+CHANGE_INTERVAL_SEC;
|
cpArray_[sw_].difference(global::wallclock())+CHANGE_INTERVAL_SEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int SpeedCalc::calculateAvgSpeed() const {
|
int SpeedCalc::calculateAvgSpeed() const {
|
||||||
int64_t milliElapsed = start_.differenceInMillis(global::wallclock());
|
int64_t milliElapsed = start_.differenceInMillis(global::wallclock());
|
||||||
|
|
||||||
// if milliElapsed is too small, the average speed is rubish, better return 0
|
// if milliElapsed is too small, the average speed is rubish, better return 0
|
||||||
if(milliElapsed > 4) {
|
if(milliElapsed > 4) {
|
||||||
unsigned int speed = accumulatedLength_*1000/milliElapsed;
|
int speed = accumulatedLength_*1000/milliElapsed;
|
||||||
return speed;
|
return speed;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -45,8 +45,8 @@ private:
|
||||||
int64_t lengthArray_[2];
|
int64_t lengthArray_[2];
|
||||||
int sw_;
|
int sw_;
|
||||||
Timer cpArray_[2];
|
Timer cpArray_[2];
|
||||||
unsigned int maxSpeed_;
|
int maxSpeed_;
|
||||||
unsigned int prevSpeed_;
|
int prevSpeed_;
|
||||||
Timer start_;
|
Timer start_;
|
||||||
int64_t accumulatedLength_;
|
int64_t accumulatedLength_;
|
||||||
time_t nextInterval_;
|
time_t nextInterval_;
|
||||||
|
@ -62,13 +62,13 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns download/upload speed in byte per sec
|
* Returns download/upload speed in byte per sec
|
||||||
*/
|
*/
|
||||||
unsigned int calculateSpeed();
|
int calculateSpeed();
|
||||||
|
|
||||||
unsigned int getMaxSpeed() const {
|
int getMaxSpeed() const {
|
||||||
return maxSpeed_;
|
return maxSpeed_;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int calculateAvgSpeed() const;
|
int calculateAvgSpeed() const;
|
||||||
|
|
||||||
void update(size_t bytes);
|
void update(size_t bytes);
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,8 @@ namespace aria2 {
|
||||||
|
|
||||||
class TransferStat {
|
class TransferStat {
|
||||||
public:
|
public:
|
||||||
unsigned int downloadSpeed;
|
int downloadSpeed;
|
||||||
unsigned int uploadSpeed;
|
int uploadSpeed;
|
||||||
int64_t sessionDownloadLength;
|
int64_t sessionDownloadLength;
|
||||||
int64_t sessionUploadLength;
|
int64_t sessionUploadLength;
|
||||||
int64_t allTimeUploadLength;
|
int64_t allTimeUploadLength;
|
||||||
|
@ -82,17 +82,17 @@ public:
|
||||||
|
|
||||||
TransferStat& operator-=(const TransferStat& stat);
|
TransferStat& operator-=(const TransferStat& stat);
|
||||||
|
|
||||||
unsigned int getDownloadSpeed() const {
|
int getDownloadSpeed() const {
|
||||||
return downloadSpeed;
|
return downloadSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDownloadSpeed(unsigned int s) { downloadSpeed = s; }
|
void setDownloadSpeed(int s) { downloadSpeed = s; }
|
||||||
|
|
||||||
unsigned int getUploadSpeed() const {
|
int getUploadSpeed() const {
|
||||||
return uploadSpeed;
|
return uploadSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUploadSpeed(unsigned int s) { uploadSpeed = s; }
|
void setUploadSpeed(int s) { uploadSpeed = s; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of bytes downloaded since the program started.
|
* Returns the number of bytes downloaded since the program started.
|
||||||
|
|
|
@ -136,7 +136,7 @@ std::string uitos(T value, bool comma = false)
|
||||||
str = "0";
|
str = "0";
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
unsigned int count = 0;
|
int count = 0;
|
||||||
while(value) {
|
while(value) {
|
||||||
++count;
|
++count;
|
||||||
char digit = value%10+'0';
|
char digit = value%10+'0';
|
||||||
|
|
|
@ -404,8 +404,8 @@ void DefaultBtAnnounceTest::testProcessAnnounceResponse()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("foo"), an.getTrackerID());
|
CPPUNIT_ASSERT_EQUAL(std::string("foo"), an.getTrackerID());
|
||||||
CPPUNIT_ASSERT_EQUAL((time_t)3000, an.getInterval());
|
CPPUNIT_ASSERT_EQUAL((time_t)3000, an.getInterval());
|
||||||
CPPUNIT_ASSERT_EQUAL((time_t)1800, an.getMinInterval());
|
CPPUNIT_ASSERT_EQUAL((time_t)1800, an.getMinInterval());
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)100, an.getComplete());
|
CPPUNIT_ASSERT_EQUAL(100, an.getComplete());
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)200, an.getIncomplete());
|
CPPUNIT_ASSERT_EQUAL(200, an.getIncomplete());
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, peerStorage_->getPeers().size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, peerStorage_->getPeers().size());
|
||||||
SharedHandle<Peer> peer = peerStorage_->getPeers()[0];
|
SharedHandle<Peer> peer = peerStorage_->getPeers()[0];
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), peer->getIPAddress());
|
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), peer->getIPAddress());
|
||||||
|
|
|
@ -89,7 +89,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri()
|
||||||
for(size_t i = 0; i < 6; ++i) {
|
for(size_t i = 0; i < 6; ++i) {
|
||||||
CPPUNIT_ASSERT_EQUAL(array[i%3], xuris[i]);
|
CPPUNIT_ASSERT_EQUAL(array[i%3], xuris[i]);
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)7, group->getNumConcurrentCommand());
|
CPPUNIT_ASSERT_EQUAL(7, group->getNumConcurrentCommand());
|
||||||
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"), ctx->getBasePath());
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"), ctx->getBasePath());
|
||||||
}
|
}
|
||||||
|
@ -132,8 +132,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri()
|
||||||
for(size_t i = 0; i < 2; ++i) {
|
for(size_t i = 0; i < 2; ++i) {
|
||||||
CPPUNIT_ASSERT_EQUAL(array[0], alphaURIs[i]);
|
CPPUNIT_ASSERT_EQUAL(array[0], alphaURIs[i]);
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)2,
|
CPPUNIT_ASSERT_EQUAL(2, alphaGroup->getNumConcurrentCommand());
|
||||||
alphaGroup->getNumConcurrentCommand());
|
|
||||||
SharedHandle<DownloadContext> alphaCtx = alphaGroup->getDownloadContext();
|
SharedHandle<DownloadContext> alphaCtx = alphaGroup->getDownloadContext();
|
||||||
// See filename is not assigned yet
|
// See filename is not assigned yet
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string(""), alphaCtx->getBasePath());
|
CPPUNIT_ASSERT_EQUAL(std::string(""), alphaCtx->getBasePath());
|
||||||
|
@ -167,7 +166,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri_parameterized()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://bravo/file"), uris[1]);
|
CPPUNIT_ASSERT_EQUAL(std::string("http://bravo/file"), uris[1]);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://charlie/file"), uris[2]);
|
CPPUNIT_ASSERT_EQUAL(std::string("http://charlie/file"), uris[2]);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3, group->getNumConcurrentCommand());
|
CPPUNIT_ASSERT_EQUAL(3, group->getNumConcurrentCommand());
|
||||||
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"), ctx->getBasePath());
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"), ctx->getBasePath());
|
||||||
}
|
}
|
||||||
|
@ -202,7 +201,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri_BitTorrent()
|
||||||
CPPUNIT_ASSERT_EQUAL(array[2], xuris[1]);
|
CPPUNIT_ASSERT_EQUAL(array[2], xuris[1]);
|
||||||
CPPUNIT_ASSERT_EQUAL(array[3], xuris[2]);
|
CPPUNIT_ASSERT_EQUAL(array[3], xuris[2]);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3, group->getNumConcurrentCommand());
|
CPPUNIT_ASSERT_EQUAL(3, group->getNumConcurrentCommand());
|
||||||
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"),
|
||||||
ctx->getBasePath());
|
ctx->getBasePath());
|
||||||
|
@ -211,8 +210,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri_BitTorrent()
|
||||||
std::vector<std::string> auxURIs;
|
std::vector<std::string> auxURIs;
|
||||||
torrentGroup->getDownloadContext()->getFirstFileEntry()->getUris(auxURIs);
|
torrentGroup->getDownloadContext()->getFirstFileEntry()->getUris(auxURIs);
|
||||||
CPPUNIT_ASSERT(auxURIs.empty());
|
CPPUNIT_ASSERT(auxURIs.empty());
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3,
|
CPPUNIT_ASSERT_EQUAL(3, torrentGroup->getNumConcurrentCommand());
|
||||||
torrentGroup->getNumConcurrentCommand());
|
|
||||||
SharedHandle<DownloadContext> btctx = torrentGroup->getDownloadContext();
|
SharedHandle<DownloadContext> btctx = torrentGroup->getDownloadContext();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-test"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-test"),
|
||||||
btctx->getBasePath());
|
btctx->getBasePath());
|
||||||
|
@ -254,13 +252,13 @@ void DownloadHelperTest::testCreateRequestGroupForUri_Metalink()
|
||||||
for(size_t i = 0; i < 3; ++i) {
|
for(size_t i = 0; i < 3; ++i) {
|
||||||
CPPUNIT_ASSERT_EQUAL(array[i], xuris[i]);
|
CPPUNIT_ASSERT_EQUAL(array[i], xuris[i]);
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)2, group->getNumConcurrentCommand());
|
CPPUNIT_ASSERT_EQUAL(2, group->getNumConcurrentCommand());
|
||||||
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"),
|
||||||
ctx->getBasePath());
|
ctx->getBasePath());
|
||||||
|
|
||||||
SharedHandle<RequestGroup> aria2052Group = result[1];
|
SharedHandle<RequestGroup> aria2052Group = result[1];
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)1, // because of maxconnections attribute
|
CPPUNIT_ASSERT_EQUAL(1, // because of maxconnections attribute
|
||||||
aria2052Group->getNumConcurrentCommand());
|
aria2052Group->getNumConcurrentCommand());
|
||||||
SharedHandle<DownloadContext> aria2052Ctx =
|
SharedHandle<DownloadContext> aria2052Ctx =
|
||||||
aria2052Group->getDownloadContext();
|
aria2052Group->getDownloadContext();
|
||||||
|
@ -268,8 +266,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri_Metalink()
|
||||||
aria2052Ctx->getBasePath());
|
aria2052Ctx->getBasePath());
|
||||||
|
|
||||||
SharedHandle<RequestGroup> aria2051Group = result[2];
|
SharedHandle<RequestGroup> aria2051Group = result[2];
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)2,
|
CPPUNIT_ASSERT_EQUAL(2, aria2051Group->getNumConcurrentCommand());
|
||||||
aria2051Group->getNumConcurrentCommand());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ENABLE_METALINK
|
#endif // ENABLE_METALINK
|
||||||
|
@ -294,7 +291,7 @@ void DownloadHelperTest::testCreateRequestGroupForUriList()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://alpha/file"), fileURIs[0]);
|
CPPUNIT_ASSERT_EQUAL(std::string("http://alpha/file"), fileURIs[0]);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://bravo/file"), fileURIs[1]);
|
CPPUNIT_ASSERT_EQUAL(std::string("http://bravo/file"), fileURIs[1]);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://charlie/file"), fileURIs[2]);
|
CPPUNIT_ASSERT_EQUAL(std::string("http://charlie/file"), fileURIs[2]);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3, fileGroup->getNumConcurrentCommand());
|
CPPUNIT_ASSERT_EQUAL(3, fileGroup->getNumConcurrentCommand());
|
||||||
SharedHandle<DownloadContext> fileCtx = fileGroup->getDownloadContext();
|
SharedHandle<DownloadContext> fileCtx = fileGroup->getDownloadContext();
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/mydownloads/myfile.out"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/mydownloads/myfile.out"),
|
||||||
fileCtx->getBasePath());
|
fileCtx->getBasePath());
|
||||||
|
@ -337,7 +334,7 @@ void DownloadHelperTest::testCreateRequestGroupForBitTorrent()
|
||||||
for(size_t i = 0; i < A2_ARRAY_LEN(array); ++i) {
|
for(size_t i = 0; i < A2_ARRAY_LEN(array); ++i) {
|
||||||
CPPUNIT_ASSERT_EQUAL(array[i]+"/aria2-test/aria2/src/aria2c", uris[i]);
|
CPPUNIT_ASSERT_EQUAL(array[i]+"/aria2-test/aria2/src/aria2c", uris[i]);
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)5, group->getNumConcurrentCommand());
|
CPPUNIT_ASSERT_EQUAL(5, group->getNumConcurrentCommand());
|
||||||
SharedHandle<TorrentAttribute> attrs =
|
SharedHandle<TorrentAttribute> attrs =
|
||||||
bittorrent::getTorrentAttrs(group->getDownloadContext());
|
bittorrent::getTorrentAttrs(group->getDownloadContext());
|
||||||
// http://tracker1 was deleted.
|
// http://tracker1 was deleted.
|
||||||
|
@ -394,7 +391,7 @@ void DownloadHelperTest::testCreateRequestGroupForMetalink()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://httphost/aria2-0.5.2.tar.bz2"),
|
CPPUNIT_ASSERT_EQUAL(std::string("http://httphost/aria2-0.5.2.tar.bz2"),
|
||||||
uris[1]);
|
uris[1]);
|
||||||
// See numConcurrentCommand is 1 because of maxconnections attribute.
|
// See numConcurrentCommand is 1 because of maxconnections attribute.
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)1, group->getNumConcurrentCommand());
|
CPPUNIT_ASSERT_EQUAL(1, group->getNumConcurrentCommand());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ENABLE_METALINK
|
#endif // ENABLE_METALINK
|
||||||
|
|
|
@ -102,43 +102,43 @@ void FtpConnectionTest::testReceiveResponse()
|
||||||
{
|
{
|
||||||
serverSocket_->writeData("100");
|
serverSocket_->writeData("100");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveResponse());
|
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveResponse());
|
||||||
serverSocket_->writeData(" single line response");
|
serverSocket_->writeData(" single line response");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveResponse());
|
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveResponse());
|
||||||
serverSocket_->writeData("\r\n");
|
serverSocket_->writeData("\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)100, ftp_->receiveResponse());
|
CPPUNIT_ASSERT_EQUAL(100, ftp_->receiveResponse());
|
||||||
// 2 responses in the buffer
|
// 2 responses in the buffer
|
||||||
serverSocket_->writeData("101 single1\r\n"
|
serverSocket_->writeData("101 single1\r\n"
|
||||||
"102 single2\r\n");
|
"102 single2\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)101, ftp_->receiveResponse());
|
CPPUNIT_ASSERT_EQUAL(101, ftp_->receiveResponse());
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)102, ftp_->receiveResponse());
|
CPPUNIT_ASSERT_EQUAL(102, ftp_->receiveResponse());
|
||||||
|
|
||||||
serverSocket_->writeData("103-multi line response\r\n");
|
serverSocket_->writeData("103-multi line response\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveResponse());
|
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveResponse());
|
||||||
serverSocket_->writeData("103-line2\r\n");
|
serverSocket_->writeData("103-line2\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveResponse());
|
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveResponse());
|
||||||
serverSocket_->writeData("103");
|
serverSocket_->writeData("103");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveResponse());
|
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveResponse());
|
||||||
serverSocket_->writeData(" ");
|
serverSocket_->writeData(" ");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveResponse());
|
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveResponse());
|
||||||
serverSocket_->writeData("last\r\n");
|
serverSocket_->writeData("last\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)103, ftp_->receiveResponse());
|
CPPUNIT_ASSERT_EQUAL(103, ftp_->receiveResponse());
|
||||||
|
|
||||||
serverSocket_->writeData("104-multi\r\n"
|
serverSocket_->writeData("104-multi\r\n"
|
||||||
"104 \r\n"
|
"104 \r\n"
|
||||||
"105-multi\r\n"
|
"105-multi\r\n"
|
||||||
"105 \r\n");
|
"105 \r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)104, ftp_->receiveResponse());
|
CPPUNIT_ASSERT_EQUAL(104, ftp_->receiveResponse());
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)105, ftp_->receiveResponse());
|
CPPUNIT_ASSERT_EQUAL(105, ftp_->receiveResponse());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FtpConnectionTest::testSendMdtm()
|
void FtpConnectionTest::testSendMdtm()
|
||||||
|
@ -158,10 +158,10 @@ void FtpConnectionTest::testReceiveMdtmResponse()
|
||||||
Time t;
|
Time t;
|
||||||
serverSocket_->writeData("213 20080908124312");
|
serverSocket_->writeData("213 20080908124312");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveMdtmResponse(t));
|
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveMdtmResponse(t));
|
||||||
serverSocket_->writeData("\r\n");
|
serverSocket_->writeData("\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)213, ftp_->receiveMdtmResponse(t));
|
CPPUNIT_ASSERT_EQUAL(213, ftp_->receiveMdtmResponse(t));
|
||||||
CPPUNIT_ASSERT_EQUAL((time_t)1220877792, t.getTime());
|
CPPUNIT_ASSERT_EQUAL((time_t)1220877792, t.getTime());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -169,7 +169,7 @@ void FtpConnectionTest::testReceiveMdtmResponse()
|
||||||
Time t;
|
Time t;
|
||||||
serverSocket_->writeData("213 20080908124312.014\r\n");
|
serverSocket_->writeData("213 20080908124312.014\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)213, ftp_->receiveMdtmResponse(t));
|
CPPUNIT_ASSERT_EQUAL(213, ftp_->receiveMdtmResponse(t));
|
||||||
CPPUNIT_ASSERT_EQUAL((time_t)1220877792, t.getTime());
|
CPPUNIT_ASSERT_EQUAL((time_t)1220877792, t.getTime());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -177,7 +177,7 @@ void FtpConnectionTest::testReceiveMdtmResponse()
|
||||||
Time t;
|
Time t;
|
||||||
serverSocket_->writeData("213 20080908\r\n");
|
serverSocket_->writeData("213 20080908\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)213, ftp_->receiveMdtmResponse(t));
|
CPPUNIT_ASSERT_EQUAL(213, ftp_->receiveMdtmResponse(t));
|
||||||
CPPUNIT_ASSERT(t.bad());
|
CPPUNIT_ASSERT(t.bad());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -185,7 +185,7 @@ void FtpConnectionTest::testReceiveMdtmResponse()
|
||||||
Time t;
|
Time t;
|
||||||
serverSocket_->writeData("213 20081908124312\r\n");
|
serverSocket_->writeData("213 20081908124312\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)213, ftp_->receiveMdtmResponse(t));
|
CPPUNIT_ASSERT_EQUAL(213, ftp_->receiveMdtmResponse(t));
|
||||||
// Wed Jul 8 12:43:12 2009
|
// Wed Jul 8 12:43:12 2009
|
||||||
CPPUNIT_ASSERT_EQUAL((time_t)1247056992, t.getTime());
|
CPPUNIT_ASSERT_EQUAL((time_t)1247056992, t.getTime());
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ void FtpConnectionTest::testReceiveMdtmResponse()
|
||||||
Time t;
|
Time t;
|
||||||
serverSocket_->writeData("550 File Not Found\r\n");
|
serverSocket_->writeData("550 File Not Found\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)550, ftp_->receiveMdtmResponse(t));
|
CPPUNIT_ASSERT_EQUAL(550, ftp_->receiveMdtmResponse(t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ void FtpConnectionTest::testReceiveResponse_overflow()
|
||||||
for(int i = 0; i < 64; ++i) {
|
for(int i = 0; i < 64; ++i) {
|
||||||
serverSocket_->writeData(data, sizeof(data));
|
serverSocket_->writeData(data, sizeof(data));
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveResponse());
|
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveResponse());
|
||||||
}
|
}
|
||||||
serverSocket_->writeData(data, sizeof(data));
|
serverSocket_->writeData(data, sizeof(data));
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
|
@ -233,11 +233,11 @@ void FtpConnectionTest::testReceivePwdResponse()
|
||||||
std::string pwd;
|
std::string pwd;
|
||||||
serverSocket_->writeData("257 ");
|
serverSocket_->writeData("257 ");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receivePwdResponse(pwd));
|
CPPUNIT_ASSERT_EQUAL(0, ftp_->receivePwdResponse(pwd));
|
||||||
CPPUNIT_ASSERT(pwd.empty());
|
CPPUNIT_ASSERT(pwd.empty());
|
||||||
serverSocket_->writeData("\"/dir/to\" is your directory.\r\n");
|
serverSocket_->writeData("\"/dir/to\" is your directory.\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)257, ftp_->receivePwdResponse(pwd));
|
CPPUNIT_ASSERT_EQUAL(257, ftp_->receivePwdResponse(pwd));
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/dir/to"), pwd);
|
CPPUNIT_ASSERT_EQUAL(std::string("/dir/to"), pwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ void FtpConnectionTest::testReceivePwdResponse_badStatus()
|
||||||
std::string pwd;
|
std::string pwd;
|
||||||
serverSocket_->writeData("500 failed\r\n");
|
serverSocket_->writeData("500 failed\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)500, ftp_->receivePwdResponse(pwd));
|
CPPUNIT_ASSERT_EQUAL(500, ftp_->receivePwdResponse(pwd));
|
||||||
CPPUNIT_ASSERT(pwd.empty());
|
CPPUNIT_ASSERT(pwd.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ void FtpConnectionTest::testReceiveSizeResponse()
|
||||||
serverSocket_->writeData("213 4294967296\r\n");
|
serverSocket_->writeData("213 4294967296\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
off_t size;
|
off_t size;
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)213, ftp_->receiveSizeResponse(size));
|
CPPUNIT_ASSERT_EQUAL(213, ftp_->receiveSizeResponse(size));
|
||||||
CPPUNIT_ASSERT_EQUAL((off_t)4294967296LL, size);
|
CPPUNIT_ASSERT_EQUAL((off_t)4294967296LL, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,32 +307,32 @@ void FtpConnectionTest::testReceiveEpsvResponse()
|
||||||
serverSocket_->writeData("229 Success (|||12000|)\r\n");
|
serverSocket_->writeData("229 Success (|||12000|)\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
uint16_t port = 0;
|
uint16_t port = 0;
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)229, ftp_->receiveEpsvResponse(port));
|
CPPUNIT_ASSERT_EQUAL(229, ftp_->receiveEpsvResponse(port));
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)12000, port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)12000, port);
|
||||||
|
|
||||||
serverSocket_->writeData("229 Success |||12000|)\r\n");
|
serverSocket_->writeData("229 Success |||12000|)\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)229, ftp_->receiveEpsvResponse(port));
|
CPPUNIT_ASSERT_EQUAL(229, ftp_->receiveEpsvResponse(port));
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)0, port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)0, port);
|
||||||
|
|
||||||
serverSocket_->writeData("229 Success (|||12000|\r\n");
|
serverSocket_->writeData("229 Success (|||12000|\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)229, ftp_->receiveEpsvResponse(port));
|
CPPUNIT_ASSERT_EQUAL(229, ftp_->receiveEpsvResponse(port));
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)0, port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)0, port);
|
||||||
|
|
||||||
serverSocket_->writeData("229 Success ()|||12000|\r\n");
|
serverSocket_->writeData("229 Success ()|||12000|\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)229, ftp_->receiveEpsvResponse(port));
|
CPPUNIT_ASSERT_EQUAL(229, ftp_->receiveEpsvResponse(port));
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)0, port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)0, port);
|
||||||
|
|
||||||
serverSocket_->writeData("229 Success )(|||12000|)\r\n");
|
serverSocket_->writeData("229 Success )(|||12000|)\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)229, ftp_->receiveEpsvResponse(port));
|
CPPUNIT_ASSERT_EQUAL(229, ftp_->receiveEpsvResponse(port));
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)0, port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)0, port);
|
||||||
|
|
||||||
serverSocket_->writeData("229 Success )(||12000|)\r\n");
|
serverSocket_->writeData("229 Success )(||12000|)\r\n");
|
||||||
waitRead(clientSocket_);
|
waitRead(clientSocket_);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)229, ftp_->receiveEpsvResponse(port));
|
CPPUNIT_ASSERT_EQUAL(229, ftp_->receiveEpsvResponse(port));
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)0, port);
|
CPPUNIT_ASSERT_EQUAL((uint16_t)0, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ void RequestTest::testRedirectUri()
|
||||||
CPPUNIT_ASSERT(req.redirectUri("/foo"));
|
CPPUNIT_ASSERT(req.redirectUri("/foo"));
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/foo"),
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/foo"),
|
||||||
req.getCurrentUri());
|
req.getCurrentUri());
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)1, req.getRedirectCount());
|
CPPUNIT_ASSERT_EQUAL(1, req.getRedirectCount());
|
||||||
|
|
||||||
CPPUNIT_ASSERT(req.redirectUri("http://aria.rednoah.co.jp/"));
|
CPPUNIT_ASSERT(req.redirectUri("http://aria.rednoah.co.jp/"));
|
||||||
// persistent connection flag is set to be true after redirection
|
// persistent connection flag is set to be true after redirection
|
||||||
|
@ -123,20 +123,20 @@ void RequestTest::testRedirectUri()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getFile());
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getFile());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
|
CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery());
|
||||||
// See redirect count is incremented.
|
// See redirect count is incremented.
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)2, req.getRedirectCount());
|
CPPUNIT_ASSERT_EQUAL(2, req.getRedirectCount());
|
||||||
|
|
||||||
// Give abosulute path
|
// Give abosulute path
|
||||||
CPPUNIT_ASSERT(req.redirectUri("/abspath/to/file"));
|
CPPUNIT_ASSERT(req.redirectUri("/abspath/to/file"));
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/abspath/to/file"),
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/abspath/to/file"),
|
||||||
req.getCurrentUri());
|
req.getCurrentUri());
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3, req.getRedirectCount());
|
CPPUNIT_ASSERT_EQUAL(3, req.getRedirectCount());
|
||||||
|
|
||||||
// Give relative path
|
// Give relative path
|
||||||
CPPUNIT_ASSERT(req.redirectUri("relativepath/to/file"));
|
CPPUNIT_ASSERT(req.redirectUri("relativepath/to/file"));
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/abspath/to/"
|
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/abspath/to/"
|
||||||
"relativepath/to/file"),
|
"relativepath/to/file"),
|
||||||
req.getCurrentUri());
|
req.getCurrentUri());
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)4, req.getRedirectCount());
|
CPPUNIT_ASSERT_EQUAL(4, req.getRedirectCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestTest::testRedirectUri2()
|
void RequestTest::testRedirectUri2()
|
||||||
|
|
|
@ -462,7 +462,7 @@ void RpcMethodTest::testChangeOption()
|
||||||
SharedHandle<Option> option = group->getOption();
|
SharedHandle<Option> option = group->getOption();
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)100*1024,
|
CPPUNIT_ASSERT_EQUAL(100*1024,
|
||||||
group->getMaxDownloadSpeedLimit());
|
group->getMaxDownloadSpeedLimit());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("102400"),
|
CPPUNIT_ASSERT_EQUAL(std::string("102400"),
|
||||||
option->get(PREF_MAX_DOWNLOAD_LIMIT));
|
option->get(PREF_MAX_DOWNLOAD_LIMIT));
|
||||||
|
@ -471,9 +471,9 @@ void RpcMethodTest::testChangeOption()
|
||||||
option->get(PREF_BT_REQUEST_PEER_SPEED_LIMIT));
|
option->get(PREF_BT_REQUEST_PEER_SPEED_LIMIT));
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("100"), option->get(PREF_BT_MAX_PEERS));
|
CPPUNIT_ASSERT_EQUAL(std::string("100"), option->get(PREF_BT_MAX_PEERS));
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)100, btObject->btRuntime->getMaxPeers());
|
CPPUNIT_ASSERT_EQUAL(100, btObject->btRuntime->getMaxPeers());
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)50*1024,
|
CPPUNIT_ASSERT_EQUAL(50*1024,
|
||||||
group->getMaxUploadSpeedLimit());
|
group->getMaxUploadSpeedLimit());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("51200"),
|
CPPUNIT_ASSERT_EQUAL(std::string("51200"),
|
||||||
option->get(PREF_MAX_UPLOAD_LIMIT));
|
option->get(PREF_MAX_UPLOAD_LIMIT));
|
||||||
|
@ -533,13 +533,13 @@ void RpcMethodTest::testChangeGlobalOption()
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
CPPUNIT_ASSERT_EQUAL(0, res.code);
|
||||||
CPPUNIT_ASSERT_EQUAL
|
CPPUNIT_ASSERT_EQUAL
|
||||||
((unsigned int)100*1024,
|
(100*1024,
|
||||||
e_->getRequestGroupMan()->getMaxOverallDownloadSpeedLimit());
|
e_->getRequestGroupMan()->getMaxOverallDownloadSpeedLimit());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("102400"),
|
CPPUNIT_ASSERT_EQUAL(std::string("102400"),
|
||||||
e_->getOption()->get(PREF_MAX_OVERALL_DOWNLOAD_LIMIT));
|
e_->getOption()->get(PREF_MAX_OVERALL_DOWNLOAD_LIMIT));
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
CPPUNIT_ASSERT_EQUAL
|
CPPUNIT_ASSERT_EQUAL
|
||||||
((unsigned int)50*1024,
|
(50*1024,
|
||||||
e_->getRequestGroupMan()->getMaxOverallUploadSpeedLimit());
|
e_->getRequestGroupMan()->getMaxOverallUploadSpeedLimit());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("51200"),
|
CPPUNIT_ASSERT_EQUAL(std::string("51200"),
|
||||||
e_->getOption()->get(PREF_MAX_OVERALL_UPLOAD_LIMIT));
|
e_->getOption()->get(PREF_MAX_OVERALL_UPLOAD_LIMIT));
|
||||||
|
|
|
@ -127,14 +127,10 @@ void ServerStatManTest::testLoad()
|
||||||
CPPUNIT_ASSERT(localhost_http);
|
CPPUNIT_ASSERT(localhost_http);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), localhost_http->getHostname());
|
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), localhost_http->getHostname());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http"), localhost_http->getProtocol());
|
CPPUNIT_ASSERT_EQUAL(std::string("http"), localhost_http->getProtocol());
|
||||||
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(25000),
|
CPPUNIT_ASSERT_EQUAL(25000, localhost_http->getDownloadSpeed());
|
||||||
localhost_http->getDownloadSpeed());
|
CPPUNIT_ASSERT_EQUAL(101, localhost_http->getSingleConnectionAvgSpeed());
|
||||||
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(101),
|
CPPUNIT_ASSERT_EQUAL(102, localhost_http->getMultiConnectionAvgSpeed());
|
||||||
localhost_http->getSingleConnectionAvgSpeed());
|
CPPUNIT_ASSERT_EQUAL(6, localhost_http->getCounter());
|
||||||
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(102),
|
|
||||||
localhost_http->getMultiConnectionAvgSpeed());
|
|
||||||
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(6),
|
|
||||||
localhost_http->getCounter());
|
|
||||||
CPPUNIT_ASSERT_EQUAL(static_cast<time_t>(1210000000),
|
CPPUNIT_ASSERT_EQUAL(static_cast<time_t>(1210000000),
|
||||||
localhost_http->getLastUpdated().getTime());
|
localhost_http->getLastUpdated().getTime());
|
||||||
CPPUNIT_ASSERT_EQUAL(ServerStat::OK, localhost_http->getStatus());
|
CPPUNIT_ASSERT_EQUAL(ServerStat::OK, localhost_http->getStatus());
|
||||||
|
|
Loading…
Reference in New Issue