Преглед изворни кода

Use %lld to fomat a2_gid_t

Tatsuhiro Tsujikawa пре 14 година
родитељ
комит
f860bf0d50

+ 6 - 6
src/BtDependency.cc

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

+ 2 - 2
src/BtStopDownloadCommand.cc

@@ -61,9 +61,9 @@ void BtStopDownloadCommand::preProcess()
     enableExit();
   }
   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.",
-                      util::itos(requestGroup_->getGID()).c_str()));
+                      requestGroup_->getGID()));
     requestGroup_->setForceHaltRequested(true);
     getDownloadEngine()->setRefreshInterval(0);
     enableExit();

+ 2 - 3
src/CheckIntegrityDispatcherCommand.cc

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

+ 1 - 1
src/FtpNegotiationCommand.cc

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

+ 2 - 2
src/HttpResponseCommand.cc

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

+ 6 - 11
src/RequestGroup.cc

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

+ 2 - 1
src/RequestGroup.h

@@ -73,7 +73,8 @@ class BtRuntime;
 class PeerStorage;
 #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 {
 public:

+ 3 - 5
src/RequestGroupMan.cc

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

+ 13 - 37
src/RpcMethodImpl.cc

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

+ 1 - 2
src/TrackerWatcherCommand.cc

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

+ 1 - 1
src/message.h

@@ -54,7 +54,7 @@
 #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_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_NAME_RESOLUTION_COMPLETE                    \
   "CUID#%lld - Name resolution complete: %s -> %s"