Use int instead of unsigned int where unsigned int is not needed.

pull/4/head
Tatsuhiro Tsujikawa 2011-12-08 21:38:00 +09:00
parent b97a7c8ecf
commit f0bcfa822e
54 changed files with 299 additions and 310 deletions

View File

@ -320,7 +320,7 @@ bool AbstractCommand::execute() {
req_->addTryCount();
req_->resetRedirectCount();
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;
if(isAbort) {
A2_LOG_INFO(fmt(MSG_MAX_TRY,

View File

@ -82,10 +82,9 @@ bool ActivePeerConnectionCommand::execute() {
if(checkPoint_.difference(global::wallclock()) >= interval_) {
checkPoint_ = global::wallclock();
TransferStat tstat = requestGroup_->calculateStat();
const unsigned int maxDownloadLimit =
requestGroup_->getMaxDownloadSpeedLimit();
const unsigned int maxUploadLimit = requestGroup_->getMaxUploadSpeedLimit();
unsigned int thresholdSpeed;
const int maxDownloadLimit = requestGroup_->getMaxDownloadSpeedLimit();
const int maxUploadLimit = requestGroup_->getMaxUploadSpeedLimit();
int thresholdSpeed;
if(!bittorrent::getTorrentAttrs
(requestGroup_->getDownloadContext())->metadata.empty()) {
thresholdSpeed =
@ -104,7 +103,7 @@ bool ActivePeerConnectionCommand::execute() {
(tstat.getDownloadSpeed() < thresholdSpeed ||
btRuntime_->lessThanMinPeers()))) {
unsigned int numConnection = 0;
int numConnection = 0;
if(pieceStorage_->downloadFinished()) {
if(btRuntime_->getMaxPeers() > btRuntime_->getConnections()) {
numConnection =
@ -115,7 +114,7 @@ bool ActivePeerConnectionCommand::execute() {
numConnection = numNewConnection_;
}
for(unsigned int numAdd = numConnection;
for(int numAdd = numConnection;
numAdd > 0 && peerStorage_->isPeerAvailable(); --numAdd) {
SharedHandle<Peer> peer = peerStorage_->getUnusedPeer();
connectToPeer(peer);

View File

@ -60,7 +60,7 @@ private:
time_t interval_; // UNIT: sec
DownloadEngine* e_;
Timer checkPoint_;
unsigned int numNewConnection_; // the number of the connection to establish.
int numNewConnection_; // the number of the connection to establish.
public:
ActivePeerConnectionCommand(cuid_t cuid,
RequestGroup* requestGroup,
@ -73,7 +73,7 @@ public:
void connectToPeer(const SharedHandle<Peer>& peer);
void setNumNewConnection(size_t numNewConnection)
void setNumNewConnection(int numNewConnection)
{
numNewConnection_ = numNewConnection;
}

View File

@ -125,12 +125,13 @@ std::string AdaptiveURISelector::selectOne(const std::deque<std::string>& uris)
if(uris.empty()) {
return A2STR::NIL;
} else {
const unsigned int numPieces =
const size_t numPieces =
requestGroup_->getDownloadContext()->getNumPieces();
bool reservedContext = numPieces > 0 &&
nbConnections_ > std::min(numPieces,
requestGroup_->getNumConcurrentCommand());
static_cast<size_t>(nbConnections_) > std::min
(numPieces,
static_cast<size_t>(requestGroup_->getNumConcurrentCommand()));
bool selectBest = numPieces == 0 || reservedContext;
if(numPieces > 0)
@ -180,8 +181,8 @@ std::string AdaptiveURISelector::getBestMirror
(const std::deque<std::string>& uris) const
{
/* Here we return one of the bests mirrors */
unsigned int max = getMaxDownloadSpeed(uris);
unsigned int min = max-(int)(max*0.25);
int max = getMaxDownloadSpeed(uris);
int min = max-(int)(max*0.25);
std::deque<std::string> bests = getUrisBySpeed(uris, min);
if (bests.size() < 2) {
@ -218,11 +219,11 @@ void AdaptiveURISelector::tuneDownloadCommand
void AdaptiveURISelector::adjustLowestSpeedLimit
(const std::deque<std::string>& uris, DownloadCommand* command) const
{
unsigned int lowest =
int lowest =
requestGroup_->getOption()->getAsInt(PREF_LOWEST_SPEED_LIMIT);
if (lowest > 0) {
unsigned int low_lowest = 4 * 1024;
unsigned int max = getMaxDownloadSpeed(uris);
int low_lowest = 4 * 1024;
int max = getMaxDownloadSpeed(uris);
if (max > 0 && lowest > max / 4) {
A2_LOG_NOTICE(fmt(_("Lowering lowest-speed-limit since known max speed is"
" too near (new:%d was:%d max:%d)"),
@ -241,14 +242,14 @@ void AdaptiveURISelector::adjustLowestSpeedLimit
}
namespace {
unsigned int getUriMaxSpeed(SharedHandle<ServerStat> ss)
int getUriMaxSpeed(SharedHandle<ServerStat> ss)
{
return std::max(ss->getSingleConnectionAvgSpeed(),
ss->getMultiConnectionAvgSpeed());
}
} // namespace
unsigned int AdaptiveURISelector::getMaxDownloadSpeed
int AdaptiveURISelector::getMaxDownloadSpeed
(const std::deque<std::string>& uris) const
{
std::string uri = getMaxDownloadSpeedUri(uris);
@ -281,7 +282,7 @@ std::string AdaptiveURISelector::getMaxDownloadSpeedUri
}
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;
for(std::deque<std::string>::const_iterator i = uris.begin(),
@ -321,7 +322,7 @@ std::string AdaptiveURISelector::getFirstNotTestedUri
std::string AdaptiveURISelector::getFirstToTestUri
(const std::deque<std::string>& uris) const
{
unsigned int counter;
int counter;
int power;
for(std::deque<std::string>::const_iterator i = uris.begin(),
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
{
unsigned int counter = 0;
int counter = 0;
for(std::deque<std::string>::const_iterator i = uris.begin(),
eoi = uris.end(); i != eoi; ++i) {
SharedHandle<ServerStat> ss = getServerStats(*i);

View File

@ -49,8 +49,8 @@ private:
SharedHandle<ServerStatMan> serverStatMan_;
// No need to delete requestGroup_
RequestGroup* requestGroup_;
unsigned int nbServerToEvaluate_;
unsigned int nbConnections_;
int nbServerToEvaluate_;
int nbConnections_;
static const time_t MAX_TIMEOUT = 60;
@ -59,15 +59,15 @@ private:
std::string selectOne(const std::deque<std::string>& uris);
void adjustLowestSpeedLimit(const std::deque<std::string>& uris,
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::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 getFirstNotTestedUri(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;
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;
public:
AdaptiveURISelector(const SharedHandle<ServerStatMan>& serverStatMan,

View File

@ -91,7 +91,7 @@ const SharedHandle<Peer>& BtLeecherStateChoke::PeerEntry::getPeer() const
return peer_;
}
unsigned int BtLeecherStateChoke::PeerEntry::getDownloadSpeed() const
int BtLeecherStateChoke::PeerEntry::getDownloadSpeed() const
{
return downloadSpeed_;
}
@ -178,7 +178,7 @@ void BtLeecherStateChoke::regularUnchoke(std::vector<PeerEntry>& peerEntries)
std::vector<PeerEntry>::iterator peerIter = peerEntries.begin();
for(;peerIter != rest && count; ++peerIter, --count) {
(*peerIter).disableChokingRequired();
A2_LOG_INFO(fmt("RU: %s, dlspd=%u",
A2_LOG_INFO(fmt("RU: %s, dlspd=%d",
(*peerIter).getPeer()->getIPAddress().c_str(),
(*peerIter).getDownloadSpeed()));
if((*peerIter).getPeer()->optUnchoking()) {

View File

@ -55,7 +55,7 @@ private:
class PeerEntry {
private:
SharedHandle<Peer> peer_;
unsigned int downloadSpeed_;
int downloadSpeed_;
bool regularUnchoker_;
public:
PeerEntry(const SharedHandle<Peer>& peer);
@ -70,7 +70,7 @@ private:
const SharedHandle<Peer>& getPeer() const;
unsigned int getDownloadSpeed() const;
int getDownloadSpeed() const;
bool isRegularUnchoker() const;

View File

@ -136,7 +136,7 @@ void BtPieceMessage::doReceivedAction()
}
}
} 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(),
static_cast<unsigned long>(index_),
begin_));

View File

@ -48,10 +48,10 @@ BtRuntime::BtRuntime()
BtRuntime::~BtRuntime() {}
void BtRuntime::setMaxPeers(unsigned int maxPeers)
void BtRuntime::setMaxPeers(int maxPeers)
{
maxPeers_ = maxPeers;
minPeers_ = static_cast<unsigned int>(maxPeers*0.8);
minPeers_ = maxPeers*0.8;
if(minPeers_ == 0 && maxPeers != 0) {
minPeers_ = maxPeers;
}

View File

@ -44,17 +44,14 @@ class BtRuntime {
private:
off_t uploadLengthAtStartup_;
bool halt_;
unsigned int connections_;
int connections_;
bool ready_;
// Maximum number of peers to hold connections at the same time.
// 0 means unlimited.
unsigned int maxPeers_;
int maxPeers_;
// Minimum number of peers. This value is used for getting more peers from
// tracker. 0 means always the number of peers is under minimum.
unsigned int minPeers_;
static const unsigned int DEFAULT_MIN_PEERS = 40;
int minPeers_;
public:
BtRuntime();
@ -74,7 +71,7 @@ public:
halt_ = halt;
}
unsigned int getConnections() const { return connections_; }
int getConnections() const { return connections_; }
void increaseConnections() { ++connections_; }
@ -99,14 +96,15 @@ public:
void setReady(bool go) { ready_ = go; }
void setMaxPeers(unsigned int maxPeers);
void setMaxPeers(int maxPeers);
unsigned int getMaxPeers() const
int getMaxPeers() const
{
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;

View File

@ -134,7 +134,7 @@ void BtSeederStateChoke::unchoke
for(std::vector<PeerEntry>::iterator eoi = peers.end();
r != eoi && count; ++r, --count) {
(*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).getUploadSpeed()));
}

View File

@ -58,7 +58,7 @@ private:
size_t outstandingUpload_;
Timer lastAmUnchoking_;
bool recentUnchoking_;
unsigned int uploadSpeed_;
int uploadSpeed_;
const static time_t TIME_FRAME = 20;
public:
@ -74,7 +74,7 @@ private:
const SharedHandle<Peer>& getPeer() const { return peer_; }
unsigned int getUploadSpeed() const { return uploadSpeed_; }
int getUploadSpeed() const { return uploadSpeed_; }
void disableOptUnchoking();
};

View File

@ -101,7 +101,7 @@ void printProgress
const SizeFormatter& sizeFormatter)
{
TransferStat stat = rg->calculateStat();
unsigned int eta = 0;
int eta = 0;
if(rg->getTotalLength() > 0 && stat.getDownloadSpeed() > 0) {
eta = (rg->getTotalLength()-rg->getCompletedLength())/stat.getDownloadSpeed();
}

View File

@ -37,7 +37,7 @@
// Increment this if major improvements or bug fixes are made in DHT
// code. This is 2 bytes unsigned integer.
#define DHT_VERSION 3
#define DHT_VERSION 3U
#define DHT_ID_LENGTH 20

View File

@ -117,7 +117,7 @@ void DHTNode::timeout()
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(),
ipaddr_.c_str(),
port_,

View File

@ -54,9 +54,9 @@ private:
uint16_t port_;
// in milli sec
unsigned int rtt_;
int rtt_;
unsigned int condition_;
int condition_;
Timer lastContact_;
public:
@ -76,7 +76,7 @@ public:
return id_;
}
void updateRTT(unsigned int millisec)
void updateRTT(int millisec)
{
rtt_ = millisec;
}

View File

@ -137,7 +137,7 @@ std::string DefaultBtAnnounce::getAnnounceUrl() {
} else {
return A2STR::NIL;
}
unsigned int numWant = 50;
int numWant = 50;
if(!btRuntime_->lessThanMinPeers() || btRuntime_->isHalt()) {
numWant = 0;
}
@ -155,7 +155,7 @@ std::string DefaultBtAnnounce::getAnnounceUrl() {
"left=%lld&"
"compact=1&"
"key=%s&"
"numwant=%u&"
"numwant=%d&"
"no_peer_id=1",
util::torrentPercentEncode
(bittorrent::getInfoHash(downloadContext_),

View File

@ -51,13 +51,13 @@ class Randomizer;
class DefaultBtAnnounce : public BtAnnounce {
private:
SharedHandle<DownloadContext> downloadContext_;
unsigned int trackers_;
int trackers_;
Timer prevAnnounceTimer_;
time_t interval_;
time_t minInterval_;
time_t userDefinedInterval_;
unsigned int complete_;
unsigned int incomplete_;
int complete_;
int incomplete_;
AnnounceList announceList_;
std::string trackerId_;
const Option* option_;
@ -139,12 +139,12 @@ public:
return minInterval_;
}
unsigned int getComplete() const
int getComplete() const
{
return complete_;
}
unsigned int getIncomplete() const
int getIncomplete() const
{
return incomplete_;
}

View File

@ -64,28 +64,28 @@ class UTMetadataRequestTracker;
class FloodingStat {
private:
unsigned int chokeUnchokeCount;
unsigned int keepAliveCount;
int chokeUnchokeCount;
int keepAliveCount;
public:
FloodingStat():chokeUnchokeCount(0), keepAliveCount(0) {}
void incChokeUnchokeCount() {
if(chokeUnchokeCount < UINT_MAX) {
if(chokeUnchokeCount < INT_MAX) {
chokeUnchokeCount++;
}
}
void incKeepAliveCount() {
if(keepAliveCount < UINT_MAX) {
if(keepAliveCount < INT_MAX) {
keepAliveCount++;
}
}
unsigned int getChokeUnchokeCount() const {
int getChokeUnchokeCount() const {
return chokeUnchokeCount;
}
unsigned int getKeepAliveCount() const {
int getKeepAliveCount() const {
return keepAliveCount;
}

View File

@ -275,7 +275,7 @@ void DownloadCommand::checkLowestDownloadSpeed() const
if(lowestDownloadSpeedLimit_ > 0 &&
peerStat_->getDownloadStartTime().difference(global::wallclock()) >=
startupIdleTime_) {
unsigned int nowSpeed = peerStat_->calculateDownloadSpeed();
int nowSpeed = peerStat_->calculateDownloadSpeed();
if(nowSpeed <= lowestDownloadSpeedLimit_) {
throw DL_ABORT_EX2(fmt(EX_TOO_SLOW_DOWNLOAD_SPEED,
nowSpeed,

View File

@ -50,7 +50,7 @@ class MessageDigest;
class DownloadCommand : public AbstractCommand {
private:
time_t startupIdleTime_;
unsigned int lowestDownloadSpeedLimit_;
int lowestDownloadSpeedLimit_;
SharedHandle<PeerStat> peerStat_;
bool pieceHashValidationEnabled_;
@ -99,7 +99,7 @@ public:
startupIdleTime_ = startupIdleTime;
}
void setLowestDownloadSpeedLimit(unsigned int lowestDownloadSpeedLimit)
void setLowestDownloadSpeedLimit(int lowestDownloadSpeedLimit)
{
lowestDownloadSpeedLimit_ = lowestDownloadSpeedLimit;
}

View File

@ -126,7 +126,7 @@ std::string FeedbackURISelector::selectFaster
// Use first 10 good URIs to introduce some randomness.
const size_t NUM_URI = 10;
// 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::string> normCands;
for(std::deque<std::string>::const_iterator i = uris.begin(),

View File

@ -230,7 +230,7 @@ FileEntry::findFasterRequest
const SharedHandle<ServerStatMan>& serverStatMan)
{
const int startupIdleTime = 10;
const unsigned int SPEED_THRESHOLD = 20*1024;
const int SPEED_THRESHOLD = 20*1024;
if(lastFasterReplace_.difference(global::wallclock()) < startupIdleTime) {
return SharedHandle<Request>();
}

View File

@ -235,11 +235,11 @@ bool FtpConnection::sendPort(const SharedHandle<SocketCore>& serverSocket)
if(socketBuffer_.sendBufferIsEmpty()) {
std::pair<std::string, uint16_t> addrinfo;
socket_->getAddrInfo(addrinfo);
unsigned int ipaddr[4];
sscanf(addrinfo.first.c_str(), "%u.%u.%u.%u",
int ipaddr[4];
sscanf(addrinfo.first.c_str(), "%d.%d.%d.%d",
&ipaddr[0], &ipaddr[1], &ipaddr[2], &ipaddr[3]);
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],
addrinfo.second/256, addrinfo.second%256);
A2_LOG_INFO(fmt(MSG_SENDING_REQUEST,
@ -280,16 +280,16 @@ bool FtpConnection::sendRetr()
return socketBuffer_.sendBufferIsEmpty();
}
unsigned int FtpConnection::getStatus(const std::string& response) const
int FtpConnection::getStatus(const std::string& response) const
{
unsigned int status;
// When the response is not like "%u %*s",
int status;
// When the response is not like "%d %*s",
// we return 0.
if(response.find_first_not_of("0123456789") != 3
|| !(response.find(" ") == 3 || response.find("-") == 3)) {
return 0;
}
if(sscanf(response.c_str(), "%u %*s", &status) == 1) {
if(sscanf(response.c_str(), "%d %*s", &status) == 1) {
return status;
} else {
return 0;
@ -300,8 +300,8 @@ unsigned int FtpConnection::getStatus(const std::string& response) const
// The length includes \r\n.
// If the whole response has not been received, then returns std::string::npos.
std::string::size_type
FtpConnection::findEndOfResponse(unsigned int status,
const std::string& buf) const
FtpConnection::findEndOfResponse
(int status, const std::string& buf) const
{
if(buf.size() <= 4) {
return std::string::npos;
@ -310,7 +310,7 @@ FtpConnection::findEndOfResponse(unsigned int status,
if(buf.at(3) == '-') {
// multi line response
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) {
return std::string::npos;
}
@ -331,8 +331,7 @@ FtpConnection::findEndOfResponse(unsigned int status,
}
}
bool FtpConnection::bulkReceiveResponse
(std::pair<unsigned int, std::string>& response)
bool FtpConnection::bulkReceiveResponse(std::pair<int, std::string>& response)
{
char buf[1024];
while(1) {
@ -352,7 +351,7 @@ bool FtpConnection::bulkReceiveResponse
}
strbuf_.append(&buf[0], &buf[size]);
}
unsigned int status;
int status;
if(strbuf_.size() >= 4) {
status = getStatus(strbuf_);
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)) {
return response.first;
} else {
@ -400,9 +399,9 @@ unsigned int FtpConnection::receiveResponse()
# define ULONGLONG_SCANF "%Lu"
#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(response.first == 213) {
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.
std::pair<unsigned int, std::string> response;
std::pair<int, std::string> response;
if(bulkReceiveResponse(response)) {
if(response.first == 213) {
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(response.first == 229) {
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<unsigned int, std::string> response;
std::pair<int, std::string> response;
if(bulkReceiveResponse(response)) {
if(response.first == 227) {
// we assume the format of response is "227 Entering Passive
// 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("(");
if(p >= 4) {
sscanf(response.second.c_str()+p,
"(%u,%u,%u,%u,%u,%u).",
"(%d,%d,%d,%d,%d,%d).",
&h1, &h2, &h3, &h4, &p1, &p2);
// 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
dest.second = 256*p1+p2;
} 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(response.first == 257) {
std::string::size_type first;

View File

@ -69,10 +69,10 @@ private:
std::string baseWorkingDir_;
unsigned int getStatus(const std::string& response) const;
std::string::size_type findEndOfResponse(unsigned int status,
const std::string& buf) const;
bool bulkReceiveResponse(std::pair<unsigned int, std::string>& response);
int getStatus(const std::string& response) const;
std::string::size_type findEndOfResponse
(int status, const std::string& buf) const;
bool bulkReceiveResponse(std::pair<int, std::string>& response);
static const std::string A;
@ -101,18 +101,18 @@ public:
bool sendRest(const SharedHandle<Segment>& segment);
bool sendRetr();
unsigned int receiveResponse();
unsigned int receiveSizeResponse(off_t& size);
int receiveResponse();
int receiveSizeResponse(off_t& size);
// Returns status code of MDTM reply. If the status code is 213, parses
// time-val and store it in time.
// 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
// date cannot be parsed, then assign Time::null() to given time.
// If reply is not received yet, returns 0.
unsigned int receiveMdtmResponse(Time& time);
unsigned int receiveEpsvResponse(uint16_t& port);
unsigned int receivePasvResponse(std::pair<std::string, uint16_t>& dest);
unsigned int receivePwdResponse(std::string& pwd);
int receiveMdtmResponse(Time& time);
int receiveEpsvResponse(uint16_t& port);
int receivePasvResponse(std::pair<std::string, uint16_t>& dest);
int receivePwdResponse(std::string& pwd);
void setBaseWorkingDir(const std::string& baseWorkingDir);

View File

@ -78,7 +78,7 @@ bool FtpFinishDownloadCommand::execute()
try {
if(readEventEnabled() || hupEventEnabled()) {
getCheckPoint() = global::wallclock();
unsigned int status = ftpConnection_->receiveResponse();
int status = ftpConnection_->receiveResponse();
if(status == 0) {
getDownloadEngine()->addCommand(this);
return false;

View File

@ -153,7 +153,7 @@ bool FtpNegotiationCommand::recvGreeting() {
disableWriteCheckSocket();
setReadCheckSocket(getSocket());
unsigned int status = ftp_->receiveResponse();
int status = ftp_->receiveResponse();
if(status == 0) {
return false;
}
@ -176,7 +176,7 @@ bool FtpNegotiationCommand::sendUser() {
}
bool FtpNegotiationCommand::recvUser() {
unsigned int status = ftp_->receiveResponse();
int status = ftp_->receiveResponse();
switch(status) {
case 0:
return false;
@ -204,7 +204,7 @@ bool FtpNegotiationCommand::sendPass() {
}
bool FtpNegotiationCommand::recvPass() {
unsigned int status = ftp_->receiveResponse();
int status = ftp_->receiveResponse();
if(status == 0) {
return false;
}
@ -227,7 +227,7 @@ bool FtpNegotiationCommand::sendType() {
}
bool FtpNegotiationCommand::recvType() {
unsigned int status = ftp_->receiveResponse();
int status = ftp_->receiveResponse();
if(status == 0) {
return false;
}
@ -253,7 +253,7 @@ bool FtpNegotiationCommand::sendPwd()
bool FtpNegotiationCommand::recvPwd()
{
std::string pwd;
unsigned int status = ftp_->receivePwdResponse(pwd);
int status = ftp_->receivePwdResponse(pwd);
if(status == 0) {
return false;
}
@ -292,7 +292,7 @@ bool FtpNegotiationCommand::sendCwd()
bool FtpNegotiationCommand::recvCwd()
{
unsigned int status = ftp_->receiveResponse();
int status = ftp_->receiveResponse();
if(status == 0) {
return false;
}
@ -333,7 +333,7 @@ bool FtpNegotiationCommand::sendMdtm()
bool FtpNegotiationCommand::recvMdtm()
{
Time lastModifiedTime = Time::null();
unsigned int status = ftp_->receiveMdtmResponse(lastModifiedTime);
int status = ftp_->receiveMdtmResponse(lastModifiedTime);
if(status == 0) {
return false;
}
@ -465,7 +465,7 @@ bool FtpNegotiationCommand::onFileSizeDetermined(off_t totalLength)
bool FtpNegotiationCommand::recvSize() {
off_t size = 0;
unsigned int status = ftp_->receiveSizeResponse(size);
int status = ftp_->receiveSizeResponse(size);
if(status == 0) {
return false;
}
@ -546,7 +546,7 @@ bool FtpNegotiationCommand::sendEprt() {
}
bool FtpNegotiationCommand::recvEprt() {
unsigned int status = ftp_->receiveResponse();
int status = ftp_->receiveResponse();
if(status == 0) {
return false;
}
@ -569,7 +569,7 @@ bool FtpNegotiationCommand::sendPort() {
}
bool FtpNegotiationCommand::recvPort() {
unsigned int status = ftp_->receiveResponse();
int status = ftp_->receiveResponse();
if(status == 0) {
return false;
}
@ -603,7 +603,7 @@ bool FtpNegotiationCommand::sendEpsv() {
bool FtpNegotiationCommand::recvEpsv() {
uint16_t port;
unsigned int status = ftp_->receiveEpsvResponse(port);
int status = ftp_->receiveEpsvResponse(port);
if(status == 0) {
return false;
}
@ -628,7 +628,7 @@ bool FtpNegotiationCommand::sendPasv() {
bool FtpNegotiationCommand::recvPasv() {
std::pair<std::string, uint16_t> dest;
unsigned int status = ftp_->receivePasvResponse(dest);
int status = ftp_->receivePasvResponse(dest);
if(status == 0) {
return false;
}
@ -781,7 +781,7 @@ bool FtpNegotiationCommand::sendRest(const SharedHandle<Segment>& segment) {
}
bool FtpNegotiationCommand::recvRest(const SharedHandle<Segment>& segment) {
unsigned int status = ftp_->receiveResponse();
int status = ftp_->receiveResponse();
if(status == 0) {
return false;
}
@ -808,7 +808,7 @@ bool FtpNegotiationCommand::sendRetr() {
}
bool FtpNegotiationCommand::recvRetr() {
unsigned int status = ftp_->receiveResponse();
int status = ftp_->receiveResponse();
if(status == 0) {
return false;
}

View File

@ -189,7 +189,7 @@ bool HttpSkipResponseCommand::processResponse()
{
int statusCode;
if(httpResponse_->isRedirect()) {
unsigned int rnum =
int rnum =
httpResponse_->getHttpRequest()->getRequest()->getRedirectCount();
if(rnum >= Request::MAX_REDIRECT) {
throw DL_ABORT_EX2(fmt("Too many redirects: count=%u", rnum),

View File

@ -48,7 +48,7 @@ class LpdDispatchMessageCommand:public Command {
private:
SharedHandle<LpdMessageDispatcher> dispatcher_;
DownloadEngine* e_;
unsigned int tryCount_;
int tryCount_;
SharedHandle<BtRuntime> btRuntime_;
public:
LpdDispatchMessageCommand

View File

@ -216,13 +216,13 @@ void Peer::updateBitfield(size_t index, int operation) {
updateSeeder();
}
unsigned int Peer::calculateUploadSpeed()
int Peer::calculateUploadSpeed()
{
assert(res_);
return res_->getPeerStat().calculateUploadSpeed();
}
unsigned int Peer::calculateDownloadSpeed()
int Peer::calculateDownloadSpeed()
{
assert(res_);
return res_->getPeerStat().calculateDownloadSpeed();

View File

@ -224,12 +224,12 @@ public:
/**
* Returns the transfer rate from localhost to remote host.
*/
unsigned int calculateUploadSpeed();
int calculateUploadSpeed();
/**
* Returns the transfer rate from remote host to localhost.
*/
unsigned int calculateDownloadSpeed();
int calculateDownloadSpeed();
/**
* Returns the number of bytes uploaded to the remote host.

View File

@ -127,9 +127,9 @@ bool PeerReceiveHandshakeCommand::executeInternal()
}
TransferStat tstat =
downloadContext->getOwnerRequestGroup()->calculateStat();
const unsigned int maxDownloadLimit =
const int maxDownloadLimit =
downloadContext->getOwnerRequestGroup()->getMaxDownloadSpeedLimit();
unsigned int thresholdSpeed =
int thresholdSpeed =
downloadContext->getOwnerRequestGroup()->
getOption()->getAsInt(PREF_BT_REQUEST_PEER_SPEED_LIMIT);
if(maxDownloadLimit > 0) {

View File

@ -65,23 +65,23 @@ PeerStat::~PeerStat() {}
/**
* Returns current download speed in byte per sec.
*/
unsigned int PeerStat::calculateDownloadSpeed()
int PeerStat::calculateDownloadSpeed()
{
return downloadSpeed_.calculateSpeed();
}
unsigned int PeerStat::calculateAvgDownloadSpeed()
int PeerStat::calculateAvgDownloadSpeed()
{
avgDownloadSpeed_ = downloadSpeed_.calculateAvgSpeed();
return avgDownloadSpeed_;
}
unsigned int PeerStat::calculateUploadSpeed()
int PeerStat::calculateUploadSpeed()
{
return uploadSpeed_.calculateSpeed();
}
unsigned int PeerStat::calculateAvgUploadSpeed()
int PeerStat::calculateAvgUploadSpeed()
{
avgUploadSpeed_ = uploadSpeed_.calculateAvgSpeed();
return avgUploadSpeed_;
@ -99,12 +99,12 @@ void PeerStat::updateUploadLength(size_t bytes)
sessionUploadLength_ += bytes;
}
unsigned int PeerStat::getMaxDownloadSpeed() const
int PeerStat::getMaxDownloadSpeed() const
{
return downloadSpeed_.getMaxSpeed();
}
unsigned int PeerStat::getMaxUploadSpeed() const
int PeerStat::getMaxUploadSpeed() const
{
return uploadSpeed_.getMaxSpeed();
}

View File

@ -59,8 +59,8 @@ private:
SpeedCalc uploadSpeed_;
Timer downloadStartTime_;
PeerStat::STATUS status_;
unsigned int avgDownloadSpeed_;
unsigned int avgUploadSpeed_;
int avgDownloadSpeed_;
int avgUploadSpeed_;
int64_t sessionDownloadLength_;
int64_t sessionUploadLength_;
public:
@ -78,28 +78,28 @@ public:
/**
* 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 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_;
}
unsigned int getAvgUploadSpeed() const
int getAvgUploadSpeed() const
{
return avgUploadSpeed_;
}

View File

@ -144,7 +144,7 @@ void Request::resetRedirectCount()
redirectCount_ = 0;
}
void Request::setMaxPipelinedRequest(unsigned int num)
void Request::setMaxPipelinedRequest(int num)
{
maxPipelinedRequest_ = num;
}

View File

@ -63,8 +63,8 @@ private:
std::string connectedHostname_;
std::string connectedAddr_;
unsigned int tryCount_;
unsigned int redirectCount_;
int tryCount_;
int redirectCount_;
// whether or not the server supports persistent connection
bool supportsPersistentConnection_;
// enable keep-alive if possible.
@ -72,7 +72,7 @@ private:
// enable pipelining if possible.
bool pipeliningHint_;
// maximum number of pipelined requests
unsigned int maxPipelinedRequest_;
int maxPipelinedRequest_;
SharedHandle<PeerStat> peerStat_;
bool removalRequested_;
uint16_t connectedPort_;
@ -91,9 +91,9 @@ public:
bool resetUri();
void resetTryCount() { tryCount_ = 0; }
void addTryCount() { ++tryCount_; }
unsigned int getTryCount() const { return tryCount_; }
int getTryCount() const { return tryCount_; }
void resetRedirectCount();
unsigned int getRedirectCount() const { return redirectCount_; }
int getRedirectCount() const { return redirectCount_; }
// Returns URI passed by setUri()
const std::string& getUri() const { return uri_; }
const std::string& getCurrentUri() const { return currentUri_; }
@ -146,9 +146,9 @@ public:
return pipeliningHint_;
}
void setMaxPipelinedRequest(unsigned int num);
void setMaxPipelinedRequest(int num);
unsigned int getMaxPipelinedRequest() const
int getMaxPipelinedRequest() const
{
return maxPipelinedRequest_;
}
@ -230,7 +230,7 @@ public:
static const std::string PROTO_FTP;
static const unsigned int MAX_REDIRECT = 20;
static const int MAX_REDIRECT = 20;
};

View File

@ -788,8 +788,8 @@ bool RequestGroup::tryAutoFileRenaming()
if(filepath.empty()) {
return false;
}
for(unsigned int i = 1; i < 10000; ++i) {
std::string newfilename = fmt("%s.%u", filepath.c_str(), i);
for(int i = 1; i < 10000; ++i) {
std::string newfilename = fmt("%s.%d", filepath.c_str(), i);
File newfile(newfilename);
File ctrlfile(newfile.getPath()+DefaultBtProgressInfoFile::getSuffix());
if(!newfile.exists() || (newfile.exists() && ctrlfile.exists())) {
@ -808,7 +808,7 @@ void RequestGroup::createNextCommandWithAdj(std::vector<Command*>& commands,
numCommand = 1+numAdj;
} else {
numCommand = std::min(downloadContext_->getNumPieces(),
numConcurrentCommand_);
static_cast<size_t>(numConcurrentCommand_));
numCommand += numAdj;
}
if(numCommand > 0) {
@ -830,8 +830,9 @@ void RequestGroup::createNextCommand(std::vector<Command*>& commands,
if(numStreamCommand_ >= numConcurrentCommand_) {
numCommand = 0;
} else {
numCommand = std::min(downloadContext_->getNumPieces(),
numConcurrentCommand_-numStreamCommand_);
numCommand =
std::min(downloadContext_->getNumPieces(),
static_cast<size_t>(numConcurrentCommand_-numStreamCommand_));
}
}
if(numCommand > 0) {
@ -841,9 +842,9 @@ void RequestGroup::createNextCommand(std::vector<Command*>& commands,
void RequestGroup::createNextCommand(std::vector<Command*>& commands,
DownloadEngine* e,
unsigned int numCommand)
int numCommand)
{
for(; numCommand--; ) {
for(; numCommand > 0; --numCommand) {
Command* command = new CreateRequestCommand(e->newCUID(), this, e);
commands.push_back(command);
}
@ -946,9 +947,9 @@ void RequestGroup::decreaseStreamConnection()
--numStreamConnection_;
}
unsigned int RequestGroup::getNumConnection() const
int RequestGroup::getNumConnection() const
{
unsigned int numConnection = numStreamConnection_;
int numConnection = numStreamConnection_;
#ifdef ENABLE_BITTORRENT
if(btRuntime_) {
numConnection += btRuntime_->getConnections();
@ -1259,12 +1260,12 @@ void RequestGroup::updateLastModifiedTime(const Time& time)
void RequestGroup::increaseAndValidateFileNotFoundCount()
{
++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 &&
(!segmentMan_ ||
segmentMan_->calculateSessionDownloadLength() == 0)) {
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);
}
}

View File

@ -90,16 +90,16 @@ private:
SharedHandle<Option> option_;
size_t numConcurrentCommand_;
int numConcurrentCommand_;
/**
* 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_;
@ -137,7 +137,7 @@ private:
Time lastModifiedTime_;
unsigned int fileNotFoundCount_;
int fileNotFoundCount_;
// Timeout used for HTTP/FTP downloads.
time_t timeout_;
@ -152,9 +152,9 @@ private:
// just sits in memory.
bool inMemoryDownload_;
unsigned int maxDownloadSpeedLimit_;
int maxDownloadSpeedLimit_;
unsigned int maxUploadSpeedLimit_;
int maxUploadSpeedLimit_;
error_code::Value lastErrorCode_;
@ -218,7 +218,7 @@ public:
DownloadEngine* e, int numAdj);
void createNextCommand(std::vector<Command*>& commands,
DownloadEngine* e, unsigned int numCommand);
DownloadEngine* e, int numCommand);
void createNextCommand(std::vector<Command*>& commands, DownloadEngine* e);
@ -246,12 +246,12 @@ public:
void validateTotalLength(off_t actualTotalLength) const;
void setNumConcurrentCommand(unsigned int num)
void setNumConcurrentCommand(int num)
{
numConcurrentCommand_ = num;
}
unsigned int getNumConcurrentCommand() const
int getNumConcurrentCommand() const
{
return numConcurrentCommand_;
}
@ -289,13 +289,13 @@ public:
void decreaseStreamConnection();
unsigned int getNumConnection() const;
int getNumConnection() const;
void increaseNumCommand();
void decreaseNumCommand();
unsigned int getNumCommand() const
int getNumCommand() const
{
return numCommand_;
}
@ -461,22 +461,22 @@ public:
// maxUploadSpeedLimit_ == 0. Otherwise returns false.
bool doesUploadSpeedExceed();
unsigned int getMaxDownloadSpeedLimit() const
int getMaxDownloadSpeedLimit() const
{
return maxDownloadSpeedLimit_;
}
void setMaxDownloadSpeedLimit(unsigned int speed)
void setMaxDownloadSpeedLimit(int speed)
{
maxDownloadSpeedLimit_ = speed;
}
unsigned int getMaxUploadSpeedLimit() const
int getMaxUploadSpeedLimit() const
{
return maxUploadSpeedLimit_;
}
void setMaxUploadSpeedLimit(unsigned int speed)
void setMaxUploadSpeedLimit(int speed)
{
maxUploadSpeedLimit_ = speed;
}

View File

@ -79,7 +79,7 @@ namespace aria2 {
RequestGroupMan::RequestGroupMan
(const std::vector<SharedHandle<RequestGroup> >& requestGroups,
unsigned int maxSimultaneousDownloads,
int maxSimultaneousDownloads,
const Option* option)
: reservedGroups_(requestGroups.begin(), requestGroups.end()),
maxSimultaneousDownloads_(maxSimultaneousDownloads),
@ -479,12 +479,12 @@ void createInitialCommand(const SharedHandle<RequestGroup>& requestGroup,
void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
{
removeStoppedGroup(e);
if(maxSimultaneousDownloads_ <= requestGroups_.size()) {
if(static_cast<size_t>(maxSimultaneousDownloads_) <= requestGroups_.size()) {
return;
}
std::vector<SharedHandle<RequestGroup> > temp;
unsigned int count = 0;
size_t num = maxSimultaneousDownloads_-requestGroups_.size();
int count = 0;
int num = maxSimultaneousDownloads_-requestGroups_.size();
while(count < num && !reservedGroups_.empty()) {
SharedHandle<RequestGroup> groupToAdd = reservedGroups_.front();
reservedGroups_.pop_front();

View File

@ -61,15 +61,15 @@ private:
std::deque<SharedHandle<RequestGroup> > requestGroups_;
std::deque<SharedHandle<RequestGroup> > reservedGroups_;
std::deque<SharedHandle<DownloadResult> > downloadResults_;
unsigned int maxSimultaneousDownloads_;
int maxSimultaneousDownloads_;
const Option* option_;
SharedHandle<ServerStatMan> serverStatMan_;
unsigned int maxOverallDownloadSpeedLimit_;
int maxOverallDownloadSpeedLimit_;
unsigned int maxOverallUploadSpeedLimit_;
int maxOverallUploadSpeedLimit_;
// true if JSON-RPC/XML-RPC is enabled.
bool rpc_;
@ -98,7 +98,7 @@ private:
(const SharedHandle<RequestGroup>& requestGroup) const;
public:
RequestGroupMan(const std::vector<SharedHandle<RequestGroup> >& requestGroups,
unsigned int maxSimultaneousDownloads,
int maxSimultaneousDownloads,
const Option* option);
~RequestGroupMan();
@ -249,12 +249,12 @@ public:
// maxOverallDownloadSpeedLimit_ == 0. Otherwise returns false.
bool doesOverallDownloadSpeedExceed();
void setMaxOverallDownloadSpeedLimit(unsigned int speed)
void setMaxOverallDownloadSpeedLimit(int speed)
{
maxOverallDownloadSpeedLimit_ = speed;
}
unsigned int getMaxOverallDownloadSpeedLimit() const
int getMaxOverallDownloadSpeedLimit() const
{
return maxOverallDownloadSpeedLimit_;
}
@ -264,17 +264,17 @@ public:
// maxOverallUploadSpeedLimit_ == 0. Otherwise returns false.
bool doesOverallUploadSpeedExceed();
void setMaxOverallUploadSpeedLimit(unsigned int speed)
void setMaxOverallUploadSpeedLimit(int speed)
{
maxOverallUploadSpeedLimit_ = speed;
}
unsigned int getMaxOverallUploadSpeedLimit() const
int getMaxOverallUploadSpeedLimit() const
{
return maxOverallUploadSpeedLimit_;
}
void setMaxSimultaneousDownloads(unsigned int max)
void setMaxSimultaneousDownloads(int max)
{
maxSimultaneousDownloads_ = max;
}

View File

@ -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())+
A2_DELTA_MILLIS >= 250){
lastPeerStatDlspdMapUpdated_ = global::wallclock();
@ -414,7 +414,7 @@ unsigned int SegmentMan::calculateDownloadSpeed()
for(std::vector<SharedHandle<PeerStat> >::const_iterator i =
peerStats_.begin(), eoi = peerStats_.end(); i != eoi; ++i) {
if((*i)->getStatus() == PeerStat::ACTIVE) {
unsigned int s = (*i)->calculateDownloadSpeed();
int s = (*i)->calculateDownloadSpeed();
peerStatDlspdMap_[(*i)->getCuid()] = s;
speed += s;
}
@ -428,8 +428,8 @@ unsigned int SegmentMan::calculateDownloadSpeed()
void SegmentMan::updateDownloadSpeedFor(const SharedHandle<PeerStat>& pstat)
{
unsigned int newspd = pstat->calculateDownloadSpeed();
unsigned int oldSpd = peerStatDlspdMap_[pstat->getCuid()];
int newspd = pstat->calculateDownloadSpeed();
int oldSpd = peerStatDlspdMap_[pstat->getCuid()];
if(cachedDlspd_ > oldSpd) {
cachedDlspd_ -= oldSpd;
cachedDlspd_ += newspd;

View File

@ -95,11 +95,11 @@ private:
std::vector<SharedHandle<PeerStat> > fastestPeerStats_;
// key: PeerStat's cuid, value: its download speed
std::map<cuid_t, unsigned int> peerStatDlspdMap_;
std::map<cuid_t, int> peerStatDlspdMap_;
Timer lastPeerStatDlspdMapUpdated_;
unsigned int cachedDlspd_;
int cachedDlspd_;
BitfieldMan ignoreBitfield_;
@ -231,7 +231,7 @@ public:
/**
* Returns current download speed in bytes per sec.
*/
unsigned int calculateDownloadSpeed();
int calculateDownloadSpeed();
void updateDownloadSpeedFor(const SharedHandle<PeerStat>& pstat);

View File

@ -68,12 +68,12 @@ void ServerStat::setLastUpdated(const Time& time)
lastUpdated_ = time;
}
void ServerStat::setDownloadSpeed(unsigned int downloadSpeed)
void ServerStat::setDownloadSpeed(int downloadSpeed)
{
downloadSpeed_ = downloadSpeed;
}
void ServerStat::updateDownloadSpeed(unsigned int downloadSpeed)
void ServerStat::updateDownloadSpeed(int downloadSpeed)
{
downloadSpeed_ = downloadSpeed;
if(downloadSpeed > 0) {
@ -82,13 +82,12 @@ void ServerStat::updateDownloadSpeed(unsigned int downloadSpeed)
lastUpdated_.reset();
}
void ServerStat::setSingleConnectionAvgSpeed
(unsigned int singleConnectionAvgSpeed)
void ServerStat::setSingleConnectionAvgSpeed(int singleConnectionAvgSpeed)
{
singleConnectionAvgSpeed_ = singleConnectionAvgSpeed;
}
void ServerStat::updateSingleConnectionAvgSpeed(unsigned int downloadSpeed)
void ServerStat::updateSingleConnectionAvgSpeed(int downloadSpeed)
{
float avgDownloadSpeed;
if(counter_ == 0)
@ -117,13 +116,12 @@ void ServerStat::updateSingleConnectionAvgSpeed(unsigned int downloadSpeed)
singleConnectionAvgSpeed_ = (int)avgDownloadSpeed;
}
void ServerStat::setMultiConnectionAvgSpeed
(unsigned int multiConnectionAvgSpeed)
void ServerStat::setMultiConnectionAvgSpeed(int multiConnectionAvgSpeed)
{
multiConnectionAvgSpeed_ = multiConnectionAvgSpeed;
}
void ServerStat::updateMultiConnectionAvgSpeed(unsigned int downloadSpeed)
void ServerStat::updateMultiConnectionAvgSpeed(int downloadSpeed)
{
float avgDownloadSpeed;
if(counter_ == 0)
@ -151,7 +149,7 @@ void ServerStat::increaseCounter()
++counter_;
}
void ServerStat::setCounter(unsigned int value)
void ServerStat::setCounter(int value)
{
counter_ = value;
}
@ -208,8 +206,8 @@ bool ServerStat::operator==(const ServerStat& serverStat) const
std::string ServerStat::toString() const
{
return fmt("host=%s, protocol=%s, dl_speed=%u, sc_avg_speed=%u,"
" mc_avg_speed=%u, last_updated=%ld, counter=%u, status=%s",
return fmt("host=%s, protocol=%s, dl_speed=%d, sc_avg_speed=%d,"
" mc_avg_speed=%d, last_updated=%ld, counter=%d, status=%s",
getHostname().c_str(),
getProtocol().c_str(),
getDownloadSpeed(),

View File

@ -79,40 +79,40 @@ public:
// This method doesn't update _lastUpdate.
void setLastUpdated(const Time& time);
unsigned int getDownloadSpeed() const
int getDownloadSpeed() const
{
return downloadSpeed_;
}
// update download speed and update lastUpdated_
void updateDownloadSpeed(unsigned int downloadSpeed);
void updateDownloadSpeed(int downloadSpeed);
// 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_;
}
void updateSingleConnectionAvgSpeed(unsigned int downloadSpeed);
void setSingleConnectionAvgSpeed(unsigned int singleConnectionAvgSpeed);
void updateSingleConnectionAvgSpeed(int downloadSpeed);
void setSingleConnectionAvgSpeed(int singleConnectionAvgSpeed);
unsigned int getMultiConnectionAvgSpeed() const
int getMultiConnectionAvgSpeed() const
{
return multiConnectionAvgSpeed_;
}
void updateMultiConnectionAvgSpeed(unsigned int downloadSpeed);
void setMultiConnectionAvgSpeed(unsigned int singleConnectionAvgSpeed);
void updateMultiConnectionAvgSpeed(int downloadSpeed);
void setMultiConnectionAvgSpeed(int singleConnectionAvgSpeed);
unsigned int getCounter() const
int getCounter() const
{
return counter_;
}
void increaseCounter();
void setCounter(unsigned int value);
void setCounter(int value);
// This method doesn't update _lastUpdate.
void setStatus(STATUS status);
@ -153,13 +153,13 @@ private:
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_;

View File

@ -61,10 +61,10 @@ void SpeedCalc::reset() {
nextInterval_ = CHANGE_INTERVAL_SEC;
}
unsigned int SpeedCalc::calculateSpeed() {
int SpeedCalc::calculateSpeed() {
int64_t milliElapsed = cpArray_[sw_].differenceInMillis(global::wallclock());
if(milliElapsed) {
unsigned int speed = lengthArray_[sw_]*1000/milliElapsed;
int speed = lengthArray_[sw_]*1000/milliElapsed;
prevSpeed_ = speed;
maxSpeed_ = std::max(speed, maxSpeed_);
if(isIntervalOver(milliElapsed)) {
@ -102,12 +102,12 @@ void SpeedCalc::changeSw() {
cpArray_[sw_].difference(global::wallclock())+CHANGE_INTERVAL_SEC;
}
unsigned int SpeedCalc::calculateAvgSpeed() const {
int SpeedCalc::calculateAvgSpeed() const {
int64_t milliElapsed = start_.differenceInMillis(global::wallclock());
// if milliElapsed is too small, the average speed is rubish, better return 0
if(milliElapsed > 4) {
unsigned int speed = accumulatedLength_*1000/milliElapsed;
int speed = accumulatedLength_*1000/milliElapsed;
return speed;
} else {
return 0;

View File

@ -45,8 +45,8 @@ private:
int64_t lengthArray_[2];
int sw_;
Timer cpArray_[2];
unsigned int maxSpeed_;
unsigned int prevSpeed_;
int maxSpeed_;
int prevSpeed_;
Timer start_;
int64_t accumulatedLength_;
time_t nextInterval_;
@ -62,13 +62,13 @@ public:
/**
* Returns download/upload speed in byte per sec
*/
unsigned int calculateSpeed();
int calculateSpeed();
unsigned int getMaxSpeed() const {
int getMaxSpeed() const {
return maxSpeed_;
}
unsigned int calculateAvgSpeed() const;
int calculateAvgSpeed() const;
void update(size_t bytes);

View File

@ -42,8 +42,8 @@ namespace aria2 {
class TransferStat {
public:
unsigned int downloadSpeed;
unsigned int uploadSpeed;
int downloadSpeed;
int uploadSpeed;
int64_t sessionDownloadLength;
int64_t sessionUploadLength;
int64_t allTimeUploadLength;
@ -82,17 +82,17 @@ public:
TransferStat& operator-=(const TransferStat& stat);
unsigned int getDownloadSpeed() const {
int getDownloadSpeed() const {
return downloadSpeed;
}
void setDownloadSpeed(unsigned int s) { downloadSpeed = s; }
void setDownloadSpeed(int s) { downloadSpeed = s; }
unsigned int getUploadSpeed() const {
int getUploadSpeed() const {
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.

View File

@ -136,7 +136,7 @@ std::string uitos(T value, bool comma = false)
str = "0";
return str;
}
unsigned int count = 0;
int count = 0;
while(value) {
++count;
char digit = value%10+'0';

View File

@ -404,8 +404,8 @@ void DefaultBtAnnounceTest::testProcessAnnounceResponse()
CPPUNIT_ASSERT_EQUAL(std::string("foo"), an.getTrackerID());
CPPUNIT_ASSERT_EQUAL((time_t)3000, an.getInterval());
CPPUNIT_ASSERT_EQUAL((time_t)1800, an.getMinInterval());
CPPUNIT_ASSERT_EQUAL((unsigned int)100, an.getComplete());
CPPUNIT_ASSERT_EQUAL((unsigned int)200, an.getIncomplete());
CPPUNIT_ASSERT_EQUAL(100, an.getComplete());
CPPUNIT_ASSERT_EQUAL(200, an.getIncomplete());
CPPUNIT_ASSERT_EQUAL((size_t)2, peerStorage_->getPeers().size());
SharedHandle<Peer> peer = peerStorage_->getPeers()[0];
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), peer->getIPAddress());

View File

@ -89,7 +89,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri()
for(size_t i = 0; i < 6; ++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();
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) {
CPPUNIT_ASSERT_EQUAL(array[0], alphaURIs[i]);
}
CPPUNIT_ASSERT_EQUAL((unsigned int)2,
alphaGroup->getNumConcurrentCommand());
CPPUNIT_ASSERT_EQUAL(2, alphaGroup->getNumConcurrentCommand());
SharedHandle<DownloadContext> alphaCtx = alphaGroup->getDownloadContext();
// See filename is not assigned yet
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://charlie/file"), uris[2]);
CPPUNIT_ASSERT_EQUAL((unsigned int)3, group->getNumConcurrentCommand());
CPPUNIT_ASSERT_EQUAL(3, group->getNumConcurrentCommand());
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
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[3], xuris[2]);
CPPUNIT_ASSERT_EQUAL((unsigned int)3, group->getNumConcurrentCommand());
CPPUNIT_ASSERT_EQUAL(3, group->getNumConcurrentCommand());
SharedHandle<DownloadContext> ctx = group->getDownloadContext();
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"),
ctx->getBasePath());
@ -211,8 +210,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri_BitTorrent()
std::vector<std::string> auxURIs;
torrentGroup->getDownloadContext()->getFirstFileEntry()->getUris(auxURIs);
CPPUNIT_ASSERT(auxURIs.empty());
CPPUNIT_ASSERT_EQUAL((unsigned int)3,
torrentGroup->getNumConcurrentCommand());
CPPUNIT_ASSERT_EQUAL(3, torrentGroup->getNumConcurrentCommand());
SharedHandle<DownloadContext> btctx = torrentGroup->getDownloadContext();
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-test"),
btctx->getBasePath());
@ -254,13 +252,13 @@ void DownloadHelperTest::testCreateRequestGroupForUri_Metalink()
for(size_t i = 0; i < 3; ++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();
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"),
ctx->getBasePath());
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());
SharedHandle<DownloadContext> aria2052Ctx =
aria2052Group->getDownloadContext();
@ -268,8 +266,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri_Metalink()
aria2052Ctx->getBasePath());
SharedHandle<RequestGroup> aria2051Group = result[2];
CPPUNIT_ASSERT_EQUAL((unsigned int)2,
aria2051Group->getNumConcurrentCommand());
CPPUNIT_ASSERT_EQUAL(2, aria2051Group->getNumConcurrentCommand());
}
}
#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://bravo/file"), fileURIs[1]);
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();
CPPUNIT_ASSERT_EQUAL(std::string("/mydownloads/myfile.out"),
fileCtx->getBasePath());
@ -337,7 +334,7 @@ void DownloadHelperTest::testCreateRequestGroupForBitTorrent()
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((unsigned int)5, group->getNumConcurrentCommand());
CPPUNIT_ASSERT_EQUAL(5, group->getNumConcurrentCommand());
SharedHandle<TorrentAttribute> attrs =
bittorrent::getTorrentAttrs(group->getDownloadContext());
// http://tracker1 was deleted.
@ -394,7 +391,7 @@ void DownloadHelperTest::testCreateRequestGroupForMetalink()
CPPUNIT_ASSERT_EQUAL(std::string("http://httphost/aria2-0.5.2.tar.bz2"),
uris[1]);
// 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

View File

@ -102,43 +102,43 @@ void FtpConnectionTest::testReceiveResponse()
{
serverSocket_->writeData("100");
waitRead(clientSocket_);
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveResponse());
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveResponse());
serverSocket_->writeData(" single line response");
waitRead(clientSocket_);
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveResponse());
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveResponse());
serverSocket_->writeData("\r\n");
waitRead(clientSocket_);
CPPUNIT_ASSERT_EQUAL((unsigned int)100, ftp_->receiveResponse());
CPPUNIT_ASSERT_EQUAL(100, ftp_->receiveResponse());
// 2 responses in the buffer
serverSocket_->writeData("101 single1\r\n"
"102 single2\r\n");
waitRead(clientSocket_);
CPPUNIT_ASSERT_EQUAL((unsigned int)101, ftp_->receiveResponse());
CPPUNIT_ASSERT_EQUAL((unsigned int)102, ftp_->receiveResponse());
CPPUNIT_ASSERT_EQUAL(101, ftp_->receiveResponse());
CPPUNIT_ASSERT_EQUAL(102, ftp_->receiveResponse());
serverSocket_->writeData("103-multi line response\r\n");
waitRead(clientSocket_);
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveResponse());
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveResponse());
serverSocket_->writeData("103-line2\r\n");
waitRead(clientSocket_);
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveResponse());
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveResponse());
serverSocket_->writeData("103");
waitRead(clientSocket_);
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveResponse());
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveResponse());
serverSocket_->writeData(" ");
waitRead(clientSocket_);
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveResponse());
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveResponse());
serverSocket_->writeData("last\r\n");
waitRead(clientSocket_);
CPPUNIT_ASSERT_EQUAL((unsigned int)103, ftp_->receiveResponse());
CPPUNIT_ASSERT_EQUAL(103, ftp_->receiveResponse());
serverSocket_->writeData("104-multi\r\n"
"104 \r\n"
"105-multi\r\n"
"105 \r\n");
waitRead(clientSocket_);
CPPUNIT_ASSERT_EQUAL((unsigned int)104, ftp_->receiveResponse());
CPPUNIT_ASSERT_EQUAL((unsigned int)105, ftp_->receiveResponse());
CPPUNIT_ASSERT_EQUAL(104, ftp_->receiveResponse());
CPPUNIT_ASSERT_EQUAL(105, ftp_->receiveResponse());
}
void FtpConnectionTest::testSendMdtm()
@ -158,10 +158,10 @@ void FtpConnectionTest::testReceiveMdtmResponse()
Time t;
serverSocket_->writeData("213 20080908124312");
waitRead(clientSocket_);
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveMdtmResponse(t));
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveMdtmResponse(t));
serverSocket_->writeData("\r\n");
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());
}
{
@ -169,7 +169,7 @@ void FtpConnectionTest::testReceiveMdtmResponse()
Time t;
serverSocket_->writeData("213 20080908124312.014\r\n");
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());
}
{
@ -177,7 +177,7 @@ void FtpConnectionTest::testReceiveMdtmResponse()
Time t;
serverSocket_->writeData("213 20080908\r\n");
waitRead(clientSocket_);
CPPUNIT_ASSERT_EQUAL((unsigned int)213, ftp_->receiveMdtmResponse(t));
CPPUNIT_ASSERT_EQUAL(213, ftp_->receiveMdtmResponse(t));
CPPUNIT_ASSERT(t.bad());
}
{
@ -185,7 +185,7 @@ void FtpConnectionTest::testReceiveMdtmResponse()
Time t;
serverSocket_->writeData("213 20081908124312\r\n");
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
CPPUNIT_ASSERT_EQUAL((time_t)1247056992, t.getTime());
}
@ -193,7 +193,7 @@ void FtpConnectionTest::testReceiveMdtmResponse()
Time t;
serverSocket_->writeData("550 File Not Found\r\n");
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) {
serverSocket_->writeData(data, sizeof(data));
waitRead(clientSocket_);
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receiveResponse());
CPPUNIT_ASSERT_EQUAL(0, ftp_->receiveResponse());
}
serverSocket_->writeData(data, sizeof(data));
waitRead(clientSocket_);
@ -233,11 +233,11 @@ void FtpConnectionTest::testReceivePwdResponse()
std::string pwd;
serverSocket_->writeData("257 ");
waitRead(clientSocket_);
CPPUNIT_ASSERT_EQUAL((unsigned int)0, ftp_->receivePwdResponse(pwd));
CPPUNIT_ASSERT_EQUAL(0, ftp_->receivePwdResponse(pwd));
CPPUNIT_ASSERT(pwd.empty());
serverSocket_->writeData("\"/dir/to\" is your directory.\r\n");
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);
}
@ -259,7 +259,7 @@ void FtpConnectionTest::testReceivePwdResponse_badStatus()
std::string pwd;
serverSocket_->writeData("500 failed\r\n");
waitRead(clientSocket_);
CPPUNIT_ASSERT_EQUAL((unsigned int)500, ftp_->receivePwdResponse(pwd));
CPPUNIT_ASSERT_EQUAL(500, ftp_->receivePwdResponse(pwd));
CPPUNIT_ASSERT(pwd.empty());
}
@ -288,7 +288,7 @@ void FtpConnectionTest::testReceiveSizeResponse()
serverSocket_->writeData("213 4294967296\r\n");
waitRead(clientSocket_);
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);
}
@ -307,32 +307,32 @@ void FtpConnectionTest::testReceiveEpsvResponse()
serverSocket_->writeData("229 Success (|||12000|)\r\n");
waitRead(clientSocket_);
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);
serverSocket_->writeData("229 Success |||12000|)\r\n");
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);
serverSocket_->writeData("229 Success (|||12000|\r\n");
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);
serverSocket_->writeData("229 Success ()|||12000|\r\n");
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);
serverSocket_->writeData("229 Success )(|||12000|)\r\n");
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);
serverSocket_->writeData("229 Success )(||12000|)\r\n");
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);
}

View File

@ -102,7 +102,7 @@ void RequestTest::testRedirectUri()
CPPUNIT_ASSERT(req.redirectUri("/foo"));
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/foo"),
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/"));
// 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.getQuery());
// See redirect count is incremented.
CPPUNIT_ASSERT_EQUAL((unsigned int)2, req.getRedirectCount());
CPPUNIT_ASSERT_EQUAL(2, req.getRedirectCount());
// Give abosulute path
CPPUNIT_ASSERT(req.redirectUri("/abspath/to/file"));
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/abspath/to/file"),
req.getCurrentUri());
CPPUNIT_ASSERT_EQUAL((unsigned int)3, req.getRedirectCount());
CPPUNIT_ASSERT_EQUAL(3, req.getRedirectCount());
// Give relative path
CPPUNIT_ASSERT(req.redirectUri("relativepath/to/file"));
CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/abspath/to/"
"relativepath/to/file"),
req.getCurrentUri());
CPPUNIT_ASSERT_EQUAL((unsigned int)4, req.getRedirectCount());
CPPUNIT_ASSERT_EQUAL(4, req.getRedirectCount());
}
void RequestTest::testRedirectUri2()

View File

@ -462,7 +462,7 @@ void RpcMethodTest::testChangeOption()
SharedHandle<Option> option = group->getOption();
CPPUNIT_ASSERT_EQUAL(0, res.code);
CPPUNIT_ASSERT_EQUAL((unsigned int)100*1024,
CPPUNIT_ASSERT_EQUAL(100*1024,
group->getMaxDownloadSpeedLimit());
CPPUNIT_ASSERT_EQUAL(std::string("102400"),
option->get(PREF_MAX_DOWNLOAD_LIMIT));
@ -471,9 +471,9 @@ void RpcMethodTest::testChangeOption()
option->get(PREF_BT_REQUEST_PEER_SPEED_LIMIT));
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());
CPPUNIT_ASSERT_EQUAL(std::string("51200"),
option->get(PREF_MAX_UPLOAD_LIMIT));
@ -533,13 +533,13 @@ void RpcMethodTest::testChangeGlobalOption()
CPPUNIT_ASSERT_EQUAL(0, res.code);
CPPUNIT_ASSERT_EQUAL
((unsigned int)100*1024,
(100*1024,
e_->getRequestGroupMan()->getMaxOverallDownloadSpeedLimit());
CPPUNIT_ASSERT_EQUAL(std::string("102400"),
e_->getOption()->get(PREF_MAX_OVERALL_DOWNLOAD_LIMIT));
#ifdef ENABLE_BITTORRENT
CPPUNIT_ASSERT_EQUAL
((unsigned int)50*1024,
(50*1024,
e_->getRequestGroupMan()->getMaxOverallUploadSpeedLimit());
CPPUNIT_ASSERT_EQUAL(std::string("51200"),
e_->getOption()->get(PREF_MAX_OVERALL_UPLOAD_LIMIT));

View File

@ -127,14 +127,10 @@ void ServerStatManTest::testLoad()
CPPUNIT_ASSERT(localhost_http);
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), localhost_http->getHostname());
CPPUNIT_ASSERT_EQUAL(std::string("http"), localhost_http->getProtocol());
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(25000),
localhost_http->getDownloadSpeed());
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(101),
localhost_http->getSingleConnectionAvgSpeed());
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(25000, localhost_http->getDownloadSpeed());
CPPUNIT_ASSERT_EQUAL(101, localhost_http->getSingleConnectionAvgSpeed());
CPPUNIT_ASSERT_EQUAL(102, localhost_http->getMultiConnectionAvgSpeed());
CPPUNIT_ASSERT_EQUAL(6, localhost_http->getCounter());
CPPUNIT_ASSERT_EQUAL(static_cast<time_t>(1210000000),
localhost_http->getLastUpdated().getTime());
CPPUNIT_ASSERT_EQUAL(ServerStat::OK, localhost_http->getStatus());