Skip to content

Commit

Permalink
2010-11-20 Tatsuhiro Tsujikawa <[email protected]>
Browse files Browse the repository at this point in the history
	Use format specifier %lld for cuid_t. Defined cuid_t as long long
	int instead of int64_t, since g++ complains int64_t is not
	suitable for %lld.
  • Loading branch information
tatsuhiro-t committed Nov 20, 2010
1 parent 694fb30 commit 03417e9
Show file tree
Hide file tree
Showing 36 changed files with 253 additions and 246 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2010-11-20 Tatsuhiro Tsujikawa <[email protected]>

Use format specifier %lld for cuid_t. Defined cuid_t as long long
int instead of int64_t, since g++ complains int64_t is not
suitable for %lld.

2010-11-20 Tatsuhiro Tsujikawa <[email protected]>

Replaced StringFormat with fmt
Expand Down
78 changes: 39 additions & 39 deletions src/AbstractCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ AbstractCommand::~AbstractCommand() {
}

bool AbstractCommand::execute() {
A2_LOG_DEBUG(fmt("CUID#%s - socket: read:%d, write:%d, hup:%d, err:%d",
util::itos(getCuid()).c_str(),
A2_LOG_DEBUG(fmt("CUID#%lld - socket: read:%d, write:%d, hup:%d, err:%d",
getCuid(),
readEventEnabled(),
writeEventEnabled(),
hupEventEnabled(),
Expand All @@ -124,9 +124,9 @@ bool AbstractCommand::execute() {
return true;
}
if(req_ && req_->removalRequested()) {
A2_LOG_DEBUG(fmt("CUID#%s - Discard original URI=%s because it is"
A2_LOG_DEBUG(fmt("CUID#%lld - Discard original URI=%s because it is"
" requested.",
util::itos(getCuid()).c_str(), req_->getUri().c_str()));
getCuid(), req_->getUri().c_str()));
return prepareForRetry(0);
}
if(getPieceStorage()) {
Expand All @@ -136,9 +136,9 @@ bool AbstractCommand::execute() {
// This command previously has assigned segments, but it is
// canceled. So discard current request chain. Plus, if no
// segment is available when http pipelining is used.
A2_LOG_DEBUG(fmt("CUID#%s - It seems previously assigned segments"
A2_LOG_DEBUG(fmt("CUID#%lld - It seems previously assigned segments"
" are canceled. Restart.",
util::itos(getCuid()).c_str()));
getCuid()));
// Request::isPipeliningEnabled() == true means aria2
// accessed the remote server and discovered that the server
// supports pipelining.
Expand All @@ -153,8 +153,8 @@ bool AbstractCommand::execute() {
!getPieceStorage()->hasMissingUnusedPiece()) {
SharedHandle<Request> fasterRequest = fileEntry_->findFasterRequest(req_);
if(fasterRequest) {
A2_LOG_INFO(fmt("CUID#%s - Use faster Request hostname=%s, port=%u",
util::itos(getCuid()).c_str(),
A2_LOG_INFO(fmt("CUID#%lld - Use faster Request hostname=%s, port=%u",
getCuid(),
fasterRequest->getHost().c_str(),
fasterRequest->getPort()));
// Cancel current Request object and use faster one.
Expand Down Expand Up @@ -199,7 +199,7 @@ bool AbstractCommand::execute() {
// enabled... Hmm, I don't think if pipelining is enabled
// it does not go here.
A2_LOG_INFO(fmt(MSG_NO_SEGMENT_AVAILABLE,
util::itos(getCuid()).c_str()));
getCuid()));
// When all segments are ignored in SegmentMan, there are
// no URIs available, so don't retry.
if(getSegmentMan()->allSegmentsIgnored()) {
Expand Down Expand Up @@ -234,17 +234,17 @@ bool AbstractCommand::execute() {
req_->getProtocol());
ss->setError();
// Purging IP address cache to renew IP address.
A2_LOG_DEBUG(fmt("CUID#%s - Marking IP address %s as bad",
util::itos(getCuid()).c_str(),
A2_LOG_DEBUG(fmt("CUID#%lld - Marking IP address %s as bad",
getCuid(),
req_->getConnectedAddr().c_str()));
e_->markBadIPAddress(req_->getConnectedHostname(),
req_->getConnectedAddr(),
req_->getConnectedPort());
if(e_->findCachedIPAddress
(req_->getConnectedHostname(), req_->getConnectedPort()).empty()) {
A2_LOG_DEBUG(fmt("CUID#%s - All IP addresses were marked bad."
A2_LOG_DEBUG(fmt("CUID#%lld - All IP addresses were marked bad."
" Removing Entry.",
util::itos(getCuid()).c_str()));
getCuid()));
e_->removeCachedIPAddress
(req_->getConnectedHostname(), req_->getConnectedPort());
}
Expand All @@ -258,7 +258,7 @@ bool AbstractCommand::execute() {
A2_LOG_DEBUG_EX(EX_EXCEPTION_CAUGHT, err);
} else {
A2_LOG_ERROR_EX(fmt(MSG_DOWNLOAD_ABORTED,
util::itos(getCuid()).c_str(),
getCuid(),
req_->getUri().c_str()),
DL_ABORT_EX2(fmt("URI=%s", req_->getCurrentUri().c_str()),
err));
Expand All @@ -274,7 +274,7 @@ bool AbstractCommand::execute() {
} catch(DlRetryEx& err) {
assert(req_);
A2_LOG_INFO_EX(fmt(MSG_RESTARTING_DOWNLOAD,
util::itos(getCuid()).c_str(), req_->getUri().c_str()),
getCuid(), req_->getUri().c_str()),
DL_RETRY_EX2(fmt("URI=%s", req_->getCurrentUri().c_str()),
err));
req_->addTryCount();
Expand All @@ -284,10 +284,10 @@ bool AbstractCommand::execute() {
bool isAbort = maxTries != 0 && req_->getTryCount() >= maxTries;
if(isAbort) {
A2_LOG_INFO(fmt(MSG_MAX_TRY,
util::itos(getCuid()).c_str(),
getCuid(),
req_->getTryCount()));
A2_LOG_ERROR_EX(fmt(MSG_DOWNLOAD_ABORTED,
util::itos(getCuid()).c_str(),
getCuid(),
req_->getUri().c_str()),
err);
fileEntry_->addURIResult(req_->getUri(), err.getCode());
Expand Down Expand Up @@ -320,15 +320,15 @@ void AbstractCommand::tryReserved() {
// and there are no URI left. Because file length is unknown, we
// can assume that there are no in-flight request object.
if(entry->getLength() == 0 && entry->getRemainingUris().empty()) {
A2_LOG_DEBUG(fmt("CUID#%s - Not trying next request."
A2_LOG_DEBUG(fmt("CUID#%lld - Not trying next request."
" No reserved/pooled request is remaining and"
" total length is still unknown.",
util::itos(getCuid()).c_str()));
getCuid()));
return;
}
}
A2_LOG_DEBUG(fmt("CUID#%s - Trying reserved/pooled request.",
util::itos(getCuid()).c_str()));
A2_LOG_DEBUG(fmt("CUID#%lld - Trying reserved/pooled request.",
getCuid()));
std::vector<Command*> commands;
requestGroup_->createNextCommand(commands, e_, 1);
e_->setNoWait(true);
Expand All @@ -341,8 +341,8 @@ bool AbstractCommand::prepareForRetry(time_t wait) {
}
if(req_) {
fileEntry_->poolRequest(req_);
A2_LOG_DEBUG(fmt("CUID#%s - Pooling request URI=%s",
util::itos(getCuid()).c_str(), req_->getUri().c_str()));
A2_LOG_DEBUG(fmt("CUID#%lld - Pooling request URI=%s",
getCuid(), req_->getUri().c_str()));
if(getSegmentMan()) {
getSegmentMan()->recognizeSegmentFor(fileEntry_);
}
Expand All @@ -365,8 +365,8 @@ void AbstractCommand::onAbort() {
fileEntry_->removeIdenticalURI(req_->getUri());
fileEntry_->removeRequest(req_);
}
A2_LOG_DEBUG(fmt("CUID#%s - Aborting download",
util::itos(getCuid()).c_str()));
A2_LOG_DEBUG(fmt("CUID#%lld - Aborting download",
getCuid()));
if(getPieceStorage()) {
getSegmentMan()->cancelSegment(getCuid());
// Don't do following process if BitTorrent is involved or files
Expand All @@ -383,12 +383,12 @@ void AbstractCommand::onAbort() {
// Local file exists, but given servers(or at least contacted
// ones) doesn't support resume. Let's restart download from
// scratch.
A2_LOG_NOTICE(fmt("CUID#%s - Failed to resume download."
A2_LOG_NOTICE(fmt("CUID#%lld - Failed to resume download."
" Download from scratch.",
util::itos(getCuid()).c_str()));
A2_LOG_DEBUG(fmt("CUID#%s - Gathering URIs that has CANNOT_RESUME"
getCuid()));
A2_LOG_DEBUG(fmt("CUID#%lld - Gathering URIs that has CANNOT_RESUME"
" error",
util::itos(getCuid()).c_str()));
getCuid()));
// Set PREF_ALWAYS_RESUME to A2_V_TRUE to avoid repeating this
// process.
getOption()->put(PREF_ALWAYS_RESUME, A2_V_TRUE);
Expand All @@ -402,8 +402,8 @@ void AbstractCommand::onAbort() {
uris.reserve(res.size());
std::transform(res.begin(), res.end(), std::back_inserter(uris),
std::mem_fun_ref(&URIResult::getURI));
A2_LOG_DEBUG(fmt("CUID#%s - %lu URIs found.",
util::itos(getCuid()).c_str(),
A2_LOG_DEBUG(fmt("CUID#%lld - %lu URIs found.",
getCuid(),
static_cast<unsigned long int>(uris.size())));
fileEntry_->addUris(uris.begin(), uris.end());
getSegmentMan()->recognizeSegmentFor(fileEntry_);
Expand Down Expand Up @@ -605,10 +605,10 @@ SharedHandle<Request> AbstractCommand::createProxyRequest() const
if(!proxy.empty()) {
proxyRequest.reset(new Request());
if(proxyRequest->setUri(proxy)) {
A2_LOG_DEBUG(fmt("CUID#%s - Using proxy", util::itos(getCuid()).c_str()));
A2_LOG_DEBUG(fmt("CUID#%lld - Using proxy", getCuid()));
} else {
A2_LOG_DEBUG(fmt("CUID#%s - Failed to parse proxy string",
util::itos(getCuid()).c_str()));
A2_LOG_DEBUG(fmt("CUID#%lld - Failed to parse proxy string",
getCuid()));
proxyRequest.reset();
}
}
Expand All @@ -632,7 +632,7 @@ void AbstractCommand::initAsyncNameResolver(const std::string& hostname)
}
asyncNameResolver_.reset(new AsyncNameResolver(family));
A2_LOG_INFO(fmt(MSG_RESOLVING_HOSTNAME,
util::itos(getCuid()).c_str(),
getCuid(),
hostname.c_str()));
asyncNameResolver_->resolve(hostname);
setNameResolverCheck(asyncNameResolver_);
Expand All @@ -652,7 +652,7 @@ bool AbstractCommand::asyncResolveHostname()
}
throw DL_ABORT_EX
(fmt(MSG_NAME_RESOLUTION_FAILED,
util::itos(getCuid()).c_str(),
getCuid(),
asyncNameResolver_->getHostname().c_str(),
asyncNameResolver_->getError().c_str()));
default:
Expand Down Expand Up @@ -719,7 +719,7 @@ std::string AbstractCommand::resolveHostname
res.resolve(addrs, hostname);
}
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_COMPLETE,
util::itos(getCuid()).c_str(),
getCuid(),
hostname.c_str(),
strjoin(addrs.begin(), addrs.end(), ", ").c_str()));
for(std::vector<std::string>::const_iterator i = addrs.begin(),
Expand All @@ -730,7 +730,7 @@ std::string AbstractCommand::resolveHostname
} else {
ipaddr = addrs.front();
A2_LOG_INFO(fmt(MSG_DNS_CACHE_HIT,
util::itos(getCuid()).c_str(),
getCuid(),
hostname.c_str(),
strjoin(addrs.begin(), addrs.end(), ", ").c_str()));
}
Expand Down Expand Up @@ -761,7 +761,7 @@ bool AbstractCommand::checkIfConnectionEstablished
e_->markBadIPAddress(connectedHostname, connectedAddr, connectedPort);
if(!e_->findCachedIPAddress(connectedHostname, connectedPort).empty()) {
A2_LOG_INFO(fmt(MSG_CONNECT_FAILED_AND_RETRY,
util::itos(getCuid()).c_str(),
getCuid(),
connectedAddr.c_str(), connectedPort));
Command* command =
InitiateConnectionCommandFactory::createInitiateConnectionCommand
Expand Down
2 changes: 1 addition & 1 deletion src/ActivePeerConnectionCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void ActivePeerConnectionCommand::connectToPeer(const SharedHandle<Peer>& peer)
command->setPieceStorage(pieceStorage_);
e_->addCommand(command);
A2_LOG_INFO(fmt(MSG_CONNECTING_TO_PEER,
util::itos(getCuid()).c_str(),
getCuid(),
peer->getIPAddress().c_str()));
}

Expand Down
18 changes: 9 additions & 9 deletions src/BtPieceMessage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void BtPieceMessage::doReceivedAction()
SharedHandle<Piece> piece = getPieceStorage()->getPiece(index_);
off_t offset = (off_t)index_*downloadContext_->getPieceLength()+begin_;
A2_LOG_DEBUG(fmt(MSG_PIECE_RECEIVED,
util::itos(getCuid()).c_str(),
getCuid(),
static_cast<unsigned long>(index_),
begin_,
blockLength_,
Expand All @@ -118,7 +118,7 @@ void BtPieceMessage::doReceivedAction()
getPieceStorage()->getDiskAdaptor()->writeData
(block_, blockLength_, offset);
piece->completeBlock(slot.getBlockIndex());
A2_LOG_DEBUG(fmt(MSG_PIECE_BITFIELD, util::itos(getCuid()).c_str(),
A2_LOG_DEBUG(fmt(MSG_PIECE_BITFIELD, getCuid(),
util::toHex(piece->getBitfield(),
piece->getBitfieldLength()).c_str()));
piece->updateHash(begin_, block_, blockLength_);
Expand All @@ -132,8 +132,8 @@ void BtPieceMessage::doReceivedAction()
}
}
} else {
A2_LOG_DEBUG(fmt("CUID#%s - RequestSlot not found, index=%lu, begin=%u",
util::itos(getCuid()).c_str(),
A2_LOG_DEBUG(fmt("CUID#%lld - RequestSlot not found, index=%lu, begin=%u",
getCuid(),
static_cast<unsigned long>(index_),
begin_));
}
Expand Down Expand Up @@ -171,7 +171,7 @@ void BtPieceMessage::send()
size_t writtenLength;
if(!isSendingInProgress()) {
A2_LOG_INFO(fmt(MSG_SEND_PEER_MESSAGE,
util::itos(getCuid()).c_str(),
getCuid(),
getPeer()->getIPAddress().c_str(),
getPeer()->getPort(),
toString().c_str()));
Expand Down Expand Up @@ -235,7 +235,7 @@ bool BtPieceMessage::checkPieceHash(const SharedHandle<Piece>& piece)
void BtPieceMessage::onNewPiece(const SharedHandle<Piece>& piece)
{
A2_LOG_INFO(fmt(MSG_GOT_NEW_PIECE,
util::itos(getCuid()).c_str(),
getCuid(),
static_cast<unsigned long>(piece->getIndex())));
getPieceStorage()->completePiece(piece);
getPieceStorage()->advertisePiece(getCuid(), piece->getIndex());
Expand All @@ -244,7 +244,7 @@ void BtPieceMessage::onNewPiece(const SharedHandle<Piece>& piece)
void BtPieceMessage::onWrongPiece(const SharedHandle<Piece>& piece)
{
A2_LOG_INFO(fmt(MSG_GOT_WRONG_PIECE,
util::itos(getCuid()).c_str(),
getCuid(),
static_cast<unsigned long>(piece->getIndex())));
erasePieceOnDisk(piece);
piece->clearAllBlock();
Expand Down Expand Up @@ -274,7 +274,7 @@ void BtPieceMessage::onChokingEvent(const BtChokingEvent& event)
!isSendingInProgress() &&
!getPeer()->isInAmAllowedIndexSet(index_)) {
A2_LOG_DEBUG(fmt(MSG_REJECT_PIECE_CHOKED,
util::itos(getCuid()).c_str(),
getCuid(),
static_cast<unsigned long>(index_),
begin_,
blockLength_));
Expand All @@ -297,7 +297,7 @@ void BtPieceMessage::onCancelSendingPieceEvent
begin_ == event.getBegin() &&
blockLength_ == event.getLength()) {
A2_LOG_DEBUG(fmt(MSG_REJECT_PIECE_CANCEL,
util::itos(getCuid()).c_str(),
getCuid(),
static_cast<unsigned long>(index_),
begin_,
blockLength_));
Expand Down
4 changes: 2 additions & 2 deletions src/CheckIntegrityCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ bool CheckIntegrityCommand::handleException(Exception& e)
{
getDownloadEngine()->getCheckIntegrityMan()->dropPickedEntry();
A2_LOG_ERROR_EX(fmt(MSG_FILE_VALIDATION_FAILURE,
util::itos(getCuid()).c_str()),
getCuid()),
e);
A2_LOG_ERROR
(fmt(MSG_DOWNLOAD_NOT_COMPLETE,
util::itos(getCuid()).c_str(),
getCuid(),
getRequestGroup()->getDownloadContext()->getBasePath().c_str()));
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/CheckIntegrityDispatcherCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ Command* CheckIntegrityDispatcherCommand::createCommand
(const SharedHandle<CheckIntegrityEntry>& entry)
{
cuid_t newCUID = getDownloadEngine()->newCUID();
A2_LOG_INFO(fmt("CUID#%s - Dispatching CheckIntegrityCommand CUID#%s.",
util::itos(getCuid()).c_str(),
A2_LOG_INFO(fmt("CUID#%lld - Dispatching CheckIntegrityCommand CUID#%s.",
getCuid(),
util::itos(newCUID).c_str()));
return new CheckIntegrityCommand
(newCUID, entry->getRequestGroup(), getDownloadEngine(), entry);
Expand Down
2 changes: 1 addition & 1 deletion src/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

namespace aria2 {

typedef int64_t cuid_t;
typedef long long int cuid_t;

class Command {
public:
Expand Down
6 changes: 3 additions & 3 deletions src/DHTEntryPointNameResolveCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,22 @@ bool DHTEntryPointNameResolveCommand::resolveHostname
switch(resolver->getStatus()) {
case AsyncNameResolver::STATUS_READY:
A2_LOG_INFO(fmt(MSG_RESOLVING_HOSTNAME,
util::itos(getCuid()).c_str(),
getCuid(),
hostname.c_str()));
resolver->resolve(hostname);
setNameResolverCheck(resolver);
return false;
case AsyncNameResolver::STATUS_SUCCESS:
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_COMPLETE,
util::itos(getCuid()).c_str(),
getCuid(),
resolver->getHostname().c_str(),
resolver->getResolvedAddresses().front().c_str()));
return true;
break;
case AsyncNameResolver::STATUS_ERROR:
throw DL_ABORT_EX
(fmt(MSG_NAME_RESOLUTION_FAILED,
util::itos(getCuid()).c_str(),
getCuid(),
hostname.c_str(),
resolver->getError().c_str()));
default:
Expand Down
Loading

0 comments on commit 03417e9

Please sign in to comment.