Use %lld to fomat a2_gid_t

pull/4/head
Tatsuhiro Tsujikawa 2011-12-02 21:36:11 +09:00
parent bc9fb7cb65
commit f860bf0d50
11 changed files with 39 additions and 71 deletions

View File

@ -142,20 +142,20 @@ bool BtDependency::resolve()
} }
} catch(RecoverableException& e) { } catch(RecoverableException& e) {
A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, e); A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, e);
A2_LOG_INFO(fmt("BtDependency for GID#%s failed. Go without Bt.", A2_LOG_INFO(fmt("BtDependency for GID#%lld failed. Go without Bt.",
util::itos(dependant_->getGID()).c_str())); dependant_->getGID()));
return true; return true;
} }
A2_LOG_INFO(fmt("Dependency resolved for GID#%s", A2_LOG_INFO(fmt("Dependency resolved for GID#%lld",
util::itos(dependant_->getGID()).c_str())); dependant_->getGID()));
dependant_->setDownloadContext(context); dependant_->setDownloadContext(context);
return true; return true;
} else if(dependee_->getNumCommand() == 0) { } else if(dependee_->getNumCommand() == 0) {
// dependee_'s download failed. // dependee_'s download failed.
// cut reference here // cut reference here
dependee_.reset(); dependee_.reset();
A2_LOG_INFO(fmt("BtDependency for GID#%s failed. Go without Bt.", A2_LOG_INFO(fmt("BtDependency for GID#%lld failed. Go without Bt.",
util::itos(dependant_->getGID()).c_str())); dependant_->getGID()));
return true; return true;
} else { } else {
return false; return false;

View File

@ -61,9 +61,9 @@ void BtStopDownloadCommand::preProcess()
enableExit(); enableExit();
} }
if(checkPoint_.difference(global::wallclock()) >= timeout_) { if(checkPoint_.difference(global::wallclock()) >= timeout_) {
A2_LOG_NOTICE(fmt("GID#%s Stop downloading torrent due to" A2_LOG_NOTICE(fmt("GID#%lld Stop downloading torrent due to"
" --bt-stop-timeout option.", " --bt-stop-timeout option.",
util::itos(requestGroup_->getGID()).c_str())); requestGroup_->getGID()));
requestGroup_->setForceHaltRequested(true); requestGroup_->setForceHaltRequested(true);
getDownloadEngine()->setRefreshInterval(0); getDownloadEngine()->setRefreshInterval(0);
enableExit(); enableExit();

View File

@ -56,9 +56,8 @@ Command* CheckIntegrityDispatcherCommand::createCommand
(const SharedHandle<CheckIntegrityEntry>& entry) (const SharedHandle<CheckIntegrityEntry>& entry)
{ {
cuid_t newCUID = getDownloadEngine()->newCUID(); cuid_t newCUID = getDownloadEngine()->newCUID();
A2_LOG_INFO(fmt("CUID#%lld - Dispatching CheckIntegrityCommand CUID#%s.", A2_LOG_INFO(fmt("CUID#%lld - Dispatching CheckIntegrityCommand CUID#%lld.",
getCuid(), getCuid(), newCUID));
util::itos(newCUID).c_str()));
return new CheckIntegrityCommand return new CheckIntegrityCommand
(newCUID, entry->getRequestGroup(), getDownloadEngine(), entry); (newCUID, entry->getRequestGroup(), getDownloadEngine(), entry);
} }

View File

@ -409,7 +409,7 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength)
sequence_ = SEQ_DOWNLOAD_ALREADY_COMPLETED; sequence_ = SEQ_DOWNLOAD_ALREADY_COMPLETED;
A2_LOG_NOTICE A2_LOG_NOTICE
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED, (fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
util::itos(getRequestGroup()->getGID()).c_str(), getRequestGroup()->getGID(),
getRequestGroup()->getFirstFilePath().c_str())); getRequestGroup()->getFirstFilePath().c_str()));
poolConnection(); poolConnection();

View File

@ -188,7 +188,7 @@ bool HttpResponseCommand::executeInternal()
getDownloadContext()->setChecksumVerified(true); getDownloadContext()->setChecksumVerified(true);
A2_LOG_NOTICE A2_LOG_NOTICE
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED, (fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
util::itos(getRequestGroup()->getGID()).c_str(), getRequestGroup()->getGID(),
getRequestGroup()->getFirstFilePath().c_str())); getRequestGroup()->getFirstFilePath().c_str()));
poolConnection(); poolConnection();
getFileEntry()->poolRequest(getRequest()); getFileEntry()->poolRequest(getRequest());
@ -441,7 +441,7 @@ bool HttpResponseCommand::handleOtherEncoding
getDownloadContext()->setChecksumVerified(true); getDownloadContext()->setChecksumVerified(true);
A2_LOG_NOTICE A2_LOG_NOTICE
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED, (fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
util::itos(getRequestGroup()->getGID()).c_str(), getRequestGroup()->getGID(),
getRequestGroup()->getFirstFilePath().c_str())); getRequestGroup()->getFirstFilePath().c_str()));
poolConnection(); poolConnection();
return true; return true;

View File

@ -246,10 +246,8 @@ SharedHandle<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
#endif // ENABLE_MESSAGE_DIGEST #endif // ENABLE_MESSAGE_DIGEST
{ {
downloadContext_->setChecksumVerified(true); downloadContext_->setChecksumVerified(true);
A2_LOG_NOTICE A2_LOG_NOTICE(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED, gid_, downloadContext_->getBasePath().c_str()));
util::itos(gid_).c_str(),
downloadContext_->getBasePath().c_str()));
} }
} else { } else {
checkEntry.reset(new StreamCheckIntegrityEntry(this)); checkEntry.reset(new StreamCheckIntegrityEntry(this));
@ -268,10 +266,8 @@ SharedHandle<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
#endif // ENABLE_MESSAGE_DIGEST #endif // ENABLE_MESSAGE_DIGEST
{ {
downloadContext_->setChecksumVerified(true); downloadContext_->setChecksumVerified(true);
A2_LOG_NOTICE A2_LOG_NOTICE(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED, gid_, downloadContext_->getBasePath().c_str()));
util::itos(gid_).c_str(),
downloadContext_->getBasePath().c_str()));
} }
} else { } else {
loadAndOpenFile(infoFile); loadAndOpenFile(infoFile);
@ -970,7 +966,7 @@ void RequestGroup::decreaseNumCommand()
{ {
--numCommand_; --numCommand_;
if(!numCommand_ && requestGroupMan_) { if(!numCommand_ && requestGroupMan_) {
A2_LOG_DEBUG(fmt("GID#%s - Request queue check", util::itos(gid_).c_str())); A2_LOG_DEBUG(fmt("GID#%lld - Request queue check", gid_));
requestGroupMan_->requestQueueCheck(); requestGroupMan_->requestQueueCheck();
} }
} }
@ -1165,8 +1161,7 @@ bool RequestGroup::needsFileAllocation() const
DownloadResultHandle RequestGroup::createDownloadResult() const DownloadResultHandle RequestGroup::createDownloadResult() const
{ {
A2_LOG_DEBUG(fmt("GID#%s - Creating DownloadResult.", A2_LOG_DEBUG(fmt("GID#%lld - Creating DownloadResult.", gid_));
util::itos(gid_).c_str()));
TransferStat st = calculateStat(); TransferStat st = calculateStat();
SharedHandle<DownloadResult> res(new DownloadResult()); SharedHandle<DownloadResult> res(new DownloadResult());
res->gid = gid_; res->gid = gid_;

View File

@ -73,7 +73,8 @@ class BtRuntime;
class PeerStorage; class PeerStorage;
#endif // ENABLE_BITTORRENT #endif // ENABLE_BITTORRENT
typedef int64_t a2_gid_t; // To make %lld happy, we use long long int instead of int64_t.
typedef long long int a2_gid_t;
class RequestGroup { class RequestGroup {
public: public:

View File

@ -200,9 +200,7 @@ size_t RequestGroupMan::changeReservedGroupPosition
std::deque<SharedHandle<RequestGroup> >::iterator i = std::deque<SharedHandle<RequestGroup> >::iterator i =
findByGID(reservedGroups_.begin(), reservedGroups_.end(), gid); findByGID(reservedGroups_.begin(), reservedGroups_.end(), gid);
if(i == reservedGroups_.end()) { if(i == reservedGroups_.end()) {
throw DL_ABORT_EX throw DL_ABORT_EX(fmt("GID#%lld not found in the waiting queue.", gid));
(fmt("GID#%s not found in the waiting queue.",
util::itos(gid).c_str()));
} }
SharedHandle<RequestGroup> rg = *i; SharedHandle<RequestGroup> rg = *i;
const size_t maxPos = reservedGroups_.size()-1; const size_t maxPos = reservedGroups_.size()-1;
@ -341,8 +339,8 @@ public:
} }
} else { } else {
A2_LOG_NOTICE A2_LOG_NOTICE
(fmt("Download GID#%s not complete: %s", (fmt("Download GID#%lld not complete: %s",
util::itos(group->getGID()).c_str(), group->getGID(),
group->getDownloadContext()->getBasePath().c_str())); group->getDownloadContext()->getBasePath().c_str()));
group->saveControlFile(); group->saveControlFile();
} }

View File

@ -381,16 +381,12 @@ SharedHandle<ValueBase> removeDownload
if(!group) { if(!group) {
group = e->getRequestGroupMan()->findReservedGroup(gid); group = e->getRequestGroupMan()->findReservedGroup(gid);
if(!group) { if(!group) {
throw DL_ABORT_EX throw DL_ABORT_EX(fmt("Active Download not found for GID#%lld", gid));
(fmt("Active Download not found for GID#%s",
util::itos(gid).c_str()));
} }
if(group->isDependencyResolved()) { if(group->isDependencyResolved()) {
e->getRequestGroupMan()->removeReservedGroup(gid); e->getRequestGroupMan()->removeReservedGroup(gid);
} else { } else {
throw DL_ABORT_EX throw DL_ABORT_EX(fmt("GID#%lld cannot be removed now", gid));
(fmt("GID#%s cannot be removed now",
util::itos(gid).c_str()));
} }
} else { } else {
if(forceRemove) { if(forceRemove) {
@ -460,9 +456,7 @@ SharedHandle<ValueBase> pauseDownload
e->setRefreshInterval(0); e->setRefreshInterval(0);
return createGIDResponse(gid); return createGIDResponse(gid);
} else { } else {
throw DL_ABORT_EX throw DL_ABORT_EX(fmt("GID#%lld cannot be paused now", gid));
(fmt("GID#%s cannot be paused now",
util::itos(gid).c_str()));
} }
} }
} // namespace } // namespace
@ -526,9 +520,7 @@ SharedHandle<ValueBase> UnpauseRpcMethod::process
SharedHandle<RequestGroup> group = SharedHandle<RequestGroup> group =
e->getRequestGroupMan()->findReservedGroup(gid); e->getRequestGroupMan()->findReservedGroup(gid);
if(!group || !group->isPauseRequested()) { if(!group || !group->isPauseRequested()) {
throw DL_ABORT_EX throw DL_ABORT_EX(fmt("GID#%lld cannot be unpaused now", gid));
(fmt("GID#%s cannot be unpaused now",
util::itos(gid).c_str()));
} else { } else {
group->setPauseRequested(false); group->setPauseRequested(false);
e->getRequestGroupMan()->requestQueueCheck(); e->getRequestGroupMan()->requestQueueCheck();
@ -931,9 +923,7 @@ SharedHandle<ValueBase> GetFilesRpcMethod::process
SharedHandle<DownloadResult> dr = SharedHandle<DownloadResult> dr =
e->getRequestGroupMan()->findDownloadResult(gid); e->getRequestGroupMan()->findDownloadResult(gid);
if(!dr) { if(!dr) {
throw DL_ABORT_EX throw DL_ABORT_EX(fmt("No file data is available for GID#%lld", gid));
(fmt("No file data is available for GID#%s",
util::itos(gid).c_str()));
} else { } else {
createFileEntry(files, dr->fileEntries.begin(), dr->fileEntries.end(), createFileEntry(files, dr->fileEntries.begin(), dr->fileEntries.end(),
dr->totalLength, dr->pieceLength, dr->bitfield); dr->totalLength, dr->pieceLength, dr->bitfield);
@ -960,9 +950,7 @@ SharedHandle<ValueBase> GetUrisRpcMethod::process
SharedHandle<RequestGroup> group = SharedHandle<RequestGroup> group =
findRequestGroup(e->getRequestGroupMan(), gid); findRequestGroup(e->getRequestGroupMan(), gid);
if(!group) { if(!group) {
throw DL_ABORT_EX throw DL_ABORT_EX(fmt("No URI data is available for GID#%lld", gid));
(fmt("No URI data is available for GID#%s",
util::itos(gid).c_str()));
} }
SharedHandle<List> uriList = List::g(); SharedHandle<List> uriList = List::g();
// TODO Current implementation just returns first FileEntry's URIs. // TODO Current implementation just returns first FileEntry's URIs.
@ -982,9 +970,7 @@ SharedHandle<ValueBase> GetPeersRpcMethod::process
SharedHandle<RequestGroup> group = SharedHandle<RequestGroup> group =
findRequestGroup(e->getRequestGroupMan(), gid); findRequestGroup(e->getRequestGroupMan(), gid);
if(!group) { if(!group) {
throw DL_ABORT_EX throw DL_ABORT_EX(fmt("No peer data is available for GID#%lld", gid));
(fmt("No peer data is available for GID#%s",
util::itos(gid).c_str()));
} }
SharedHandle<List> peers = List::g(); SharedHandle<List> peers = List::g();
const SharedHandle<BtObject>& btObject = const SharedHandle<BtObject>& btObject =
@ -1017,9 +1003,7 @@ SharedHandle<ValueBase> TellStatusRpcMethod::process
SharedHandle<DownloadResult> ds = SharedHandle<DownloadResult> ds =
e->getRequestGroupMan()->findDownloadResult(gid); e->getRequestGroupMan()->findDownloadResult(gid);
if(!ds) { if(!ds) {
throw DL_ABORT_EX throw DL_ABORT_EX(fmt("No such download for GID#%lld", gid));
(fmt("No such download for GID#%s",
util::itos(gid).c_str()));
} }
gatherStoppedDownload(entryDict, ds, keys); gatherStoppedDownload(entryDict, ds, keys);
} else { } else {
@ -1113,9 +1097,7 @@ SharedHandle<ValueBase> RemoveDownloadResultRpcMethod::process
a2_gid_t gid = str2Gid(gidParam); a2_gid_t gid = str2Gid(gidParam);
if(!e->getRequestGroupMan()->removeDownloadResult(gid)) { if(!e->getRequestGroupMan()->removeDownloadResult(gid)) {
throw DL_ABORT_EX throw DL_ABORT_EX(fmt("Could not remove download result of GID#%lld", gid));
(fmt("Could not remove download result of GID#%s",
util::itos(gid).c_str()));
} }
return VLB_OK; return VLB_OK;
} }
@ -1213,8 +1195,7 @@ SharedHandle<ValueBase> ChangeOptionRpcMethod::process
gatherChangeableOptionForReserved(&option, optsParam); gatherChangeableOptionForReserved(&option, optsParam);
changeOption(group, option, e); changeOption(group, option, e);
} else { } else {
throw DL_ABORT_EX throw DL_ABORT_EX(fmt("Cannot change option for GID#%lld", gid));
(fmt("Cannot change option for GID#%s", util::itos(gid).c_str()));
} }
} }
return VLB_OK; return VLB_OK;
@ -1303,9 +1284,7 @@ SharedHandle<ValueBase> GetOptionRpcMethod::process
SharedHandle<RequestGroup> group = SharedHandle<RequestGroup> group =
findRequestGroup(e->getRequestGroupMan(), gid); findRequestGroup(e->getRequestGroupMan(), gid);
if(!group) { if(!group) {
throw DL_ABORT_EX throw DL_ABORT_EX(fmt("Cannot get option for GID#%lld", gid));
(fmt("Cannot get option for GID#%s",
util::itos(gid).c_str()));
} }
SharedHandle<Dict> result = Dict::g(); SharedHandle<Dict> result = Dict::g();
SharedHandle<Option> option = group->getOption(); SharedHandle<Option> option = group->getOption();
@ -1373,8 +1352,7 @@ SharedHandle<ValueBase> GetServersRpcMethod::process
SharedHandle<RequestGroup> group = SharedHandle<RequestGroup> group =
e->getRequestGroupMan()->findRequestGroup(gid); e->getRequestGroupMan()->findRequestGroup(gid);
if(!group) { if(!group) {
throw DL_ABORT_EX(fmt("No active download for GID#%s", throw DL_ABORT_EX(fmt("No active download for GID#%lld", gid));
util::itos(gid).c_str()));
} }
const SharedHandle<DownloadContext>& dctx = group->getDownloadContext(); const SharedHandle<DownloadContext>& dctx = group->getDownloadContext();
const std::vector<SharedHandle<FileEntry> >& files = dctx->getFileEntries(); const std::vector<SharedHandle<FileEntry> >& files = dctx->getFileEntries();
@ -1421,9 +1399,7 @@ SharedHandle<ValueBase> ChangeUriRpcMethod::process
SharedHandle<RequestGroup> group = SharedHandle<RequestGroup> group =
findRequestGroup(e->getRequestGroupMan(), gid); findRequestGroup(e->getRequestGroupMan(), gid);
if(!group) { if(!group) {
throw DL_ABORT_EX throw DL_ABORT_EX(fmt("Cannot remove URIs from GID#%lld", gid));
(fmt("Cannot remove URIs from GID#%s",
util::itos(gid).c_str()));
} }
const SharedHandle<DownloadContext>& dctx = group->getDownloadContext(); const SharedHandle<DownloadContext>& dctx = group->getDownloadContext();
const std::vector<SharedHandle<FileEntry> >& files = dctx->getFileEntries(); const std::vector<SharedHandle<FileEntry> >& files = dctx->getFileEntries();

View File

@ -246,8 +246,7 @@ TrackerWatcherCommand::createRequestGroup(const std::string& uri)
rg->setFileAllocationEnabled(false); rg->setFileAllocationEnabled(false);
rg->setPreLocalFileCheckEnabled(false); rg->setPreLocalFileCheckEnabled(false);
util::removeMetalinkContentTypes(rg); util::removeMetalinkContentTypes(rg);
A2_LOG_INFO(fmt("Creating tracker request group GID#%s", A2_LOG_INFO(fmt("Creating tracker request group GID#%lld", rg->getGID()));
util::itos(rg->getGID()).c_str()));
return rg; return rg;
} }

View File

@ -54,7 +54,7 @@
#define MSG_GOT_NEW_PIECE "CUID#%lld - we got new piece. index=%lu" #define MSG_GOT_NEW_PIECE "CUID#%lld - we got new piece. index=%lu"
#define MSG_GOT_WRONG_PIECE "CUID#%lld - we got wrong piece. index=%lu" #define MSG_GOT_WRONG_PIECE "CUID#%lld - we got wrong piece. index=%lu"
#define MSG_DOWNLOAD_NOT_COMPLETE "CUID#%lld - Download not complete: %s" #define MSG_DOWNLOAD_NOT_COMPLETE "CUID#%lld - Download not complete: %s"
#define MSG_DOWNLOAD_ALREADY_COMPLETED _("GID#%s - Download has already completed: %s") #define MSG_DOWNLOAD_ALREADY_COMPLETED _("GID#%lld - Download has already completed: %s")
#define MSG_RESOLVING_HOSTNAME "CUID#%lld - Resolving hostname %s" #define MSG_RESOLVING_HOSTNAME "CUID#%lld - Resolving hostname %s"
#define MSG_NAME_RESOLUTION_COMPLETE \ #define MSG_NAME_RESOLUTION_COMPLETE \
"CUID#%lld - Name resolution complete: %s -> %s" "CUID#%lld - Name resolution complete: %s -> %s"