2010-03-21 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Defined gid_t as int64_t.
	* src/BtDependency.cc
	* src/BtStopDownloadCommand.cc
	* src/FtpNegotiationCommand.cc
	* src/HttpResponseCommand.cc
	* src/RequestGroup.cc
	* src/RequestGroup.h
	* src/RequestGroupMan.cc
	* src/TrackerWatcherCommand.cc
	* src/XmlRpcMethodImpl.cc
	* src/message.h
	* test/XmlRpcMethodTest.cc
pull/1/head
Tatsuhiro Tsujikawa 2010-03-21 14:04:05 +00:00
parent de8fef01f3
commit a0d13a7fee
12 changed files with 83 additions and 43 deletions

View File

@ -1,3 +1,18 @@
2010-03-21 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Defined gid_t as int64_t.
* src/BtDependency.cc
* src/BtStopDownloadCommand.cc
* src/FtpNegotiationCommand.cc
* src/HttpResponseCommand.cc
* src/RequestGroup.cc
* src/RequestGroup.h
* src/RequestGroupMan.cc
* src/TrackerWatcherCommand.cc
* src/XmlRpcMethodImpl.cc
* src/message.h
* test/XmlRpcMethodTest.cc
2010-03-21 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Defined cuid_t as int64_t. Removed texts containing "CUID#%D" from

View File

@ -131,19 +131,26 @@ bool BtDependency::resolve()
}
} catch(RecoverableException& e) {
_logger->error(EX_EXCEPTION_CAUGHT, e);
_logger->info("BtDependency for GID#%d failed. Go without Bt.",
_dependant->getGID());
if(_logger->info()) {
_logger->info("BtDependency for GID#%s failed. Go without Bt.",
util::itos(_dependant->getGID()).c_str());
}
return true;
}
_logger->info("Dependency resolved for GID#%d", _dependant->getGID());
if(_logger->info()) {
_logger->info("Dependency resolved for GID#%s",
util::itos(_dependant->getGID()).c_str());
}
_dependant->setDownloadContext(context);
return true;
} else if(_dependee->getNumCommand() == 0) {
// _dependee's download failed.
// cut reference here
_dependee.reset();
_logger->info("BtDependency for GID#%d failed. Go without Bt.",
_dependant->getGID());
if(_logger->info()) {
_logger->info("BtDependency for GID#%s failed. Go without Bt.",
util::itos(_dependant->getGID()).c_str());
}
return true;
} else {
return false;

View File

@ -40,6 +40,7 @@
#include "DownloadContext.h"
#include "Logger.h"
#include "wallclock.h"
#include "util.h"
namespace aria2 {
@ -59,8 +60,9 @@ void BtStopDownloadCommand::preProcess()
_exit = true;
}
if(_checkPoint.difference(global::wallclock) >= _timeout) {
logger->notice("GID#%d Stop downloading torrent due to"
" --bt-stop-timeout option.", _requestGroup->getGID());
logger->notice("GID#%s Stop downloading torrent due to"
" --bt-stop-timeout option.",
util::itos(_requestGroup->getGID()).c_str());
_requestGroup->setHaltRequested(true);
_exit = true;
}

View File

@ -377,7 +377,7 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength)
sequence = SEQ_DOWNLOAD_ALREADY_COMPLETED;
logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED,
_requestGroup->getGID(),
util::itos(_requestGroup->getGID()).c_str(),
_requestGroup->getFirstFilePath().c_str());
poolConnection();
@ -416,7 +416,7 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength)
sequence = SEQ_DOWNLOAD_ALREADY_COMPLETED;
logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED,
_requestGroup->getGID(),
util::itos(_requestGroup->getGID()).c_str(),
_requestGroup->getFirstFilePath().c_str());
poolConnection();

View File

@ -234,7 +234,7 @@ bool HttpResponseCommand::handleDefaultEncoding
_requestGroup->getPieceStorage()->markAllPiecesDone();
logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED,
_requestGroup->getGID(),
util::itos(_requestGroup->getGID()).c_str(),
_requestGroup->getFirstFilePath().c_str());
return true;
@ -330,7 +330,7 @@ bool HttpResponseCommand::handleOtherEncoding
_requestGroup->getPieceStorage()->markAllPiecesDone();
logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED,
_requestGroup->getGID(),
util::itos(_requestGroup->getGID()).c_str(),
_requestGroup->getFirstFilePath().c_str());
poolConnection();

View File

@ -392,7 +392,8 @@ void RequestGroup::createInitialCommand
if(!infoFile->exists() && downloadFinishedByFileLength()) {
_pieceStorage->markAllPiecesDone();
_logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED,
_gid, _downloadContext->getBasePath().c_str());
util::itos(_gid).c_str(),
_downloadContext->getBasePath().c_str());
} else {
loadAndOpenFile(infoFile);
SharedHandle<CheckIntegrityEntry> checkIntegrityEntry
@ -825,7 +826,7 @@ void RequestGroup::decreaseNumCommand()
--_numCommand;
if(!_numCommand && _requestGroupMan) {
if(_logger->debug()) {
_logger->debug("GID#%d - Request queue check", _gid);
_logger->debug("GID#%s - Request queue check", util::itos(_gid).c_str());
}
_requestGroupMan->requestQueueCheck();
}
@ -1015,7 +1016,8 @@ bool RequestGroup::needsFileAllocation() const
DownloadResultHandle RequestGroup::createDownloadResult() const
{
if(_logger->debug()) {
_logger->debug("GID#%d - Creating DownloadResult.", _gid);
_logger->debug("GID#%s - Creating DownloadResult.",
util::itos(_gid).c_str());
}
uint64_t sessionDownloadLength = 0;
@ -1164,7 +1166,7 @@ void RequestGroup::setDownloadContext
gid_t RequestGroup::newGID()
{
if(_gidCounter == INT32_MAX) {
if(_gidCounter == INT64_MAX) {
_gidCounter = 0;
}
return ++_gidCounter;

View File

@ -73,7 +73,7 @@ class BtRuntime;
class PeerStorage;
#endif // ENABLE_BITTORRENT
typedef int32_t gid_t;
typedef int64_t gid_t;
class RequestGroup {
public:

View File

@ -197,7 +197,8 @@ size_t RequestGroupMan::changeReservedGroupPosition
findByGID(_reservedGroups.begin(), _reservedGroups.end(), gid);
if(i == _reservedGroups.end()) {
throw DL_ABORT_EX
(StringFormat("GID#%d not found in the waiting queue.", gid).str());
(StringFormat("GID#%s not found in the waiting queue.",
util::itos(gid).c_str()).str());
}
SharedHandle<RequestGroup> rg = *i;
const size_t maxPos = _reservedGroups.size()-1;
@ -247,8 +248,8 @@ bool RequestGroupMan::removeReservedGroup(gid_t gid)
static void executeHook(const std::string& command, gid_t gid)
{
LogFactory::getInstance()->info("Executing user command: %s %d",
command.c_str(), gid);
LogFactory::getInstance()->info("Executing user command: %s %s",
command.c_str(), util::itos(gid).c_str());
#ifndef __MINGW32__
pid_t cpid = fork();
if(cpid == -1) {

View File

@ -245,7 +245,10 @@ TrackerWatcherCommand::createRequestGroup(const std::string& uri)
rg->setDiskWriterFactory(dwf);
rg->setFileAllocationEnabled(false);
rg->setPreLocalFileCheckEnabled(false);
logger->info("Creating tracker request group GID#%d", rg->getGID());
if(logger->info()) {
logger->info("Creating tracker request group GID#%s",
util::itos(rg->getGID()).c_str());
}
return rg;
}

View File

@ -292,7 +292,7 @@ static BDE removeDownload
throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED);
}
gid_t gid = util::parseInt(params[0].s());
gid_t gid = util::parseLLInt(params[0].s());
SharedHandle<RequestGroup> group = e->_requestGroupMan->findRequestGroup(gid);
@ -300,13 +300,15 @@ static BDE removeDownload
group = e->_requestGroupMan->findReservedGroup(gid);
if(group.isNull()) {
throw DL_ABORT_EX
(StringFormat("Active Download not found for GID#%d", gid).str());
(StringFormat("Active Download not found for GID#%s",
util::itos(gid).c_str()).str());
}
if(group->isDependencyResolved()) {
e->_requestGroupMan->removeReservedGroup(gid);
} else {
throw DL_ABORT_EX
(StringFormat("GID#%d cannot be removed now", gid).str());
(StringFormat("GID#%s cannot be removed now",
util::itos(gid).c_str()).str());
}
} else {
if(forceRemove) {
@ -560,7 +562,7 @@ BDE GetFilesXmlRpcMethod::process
throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED);
}
gid_t gid = util::parseInt(params[0].s());
gid_t gid = util::parseLLInt(params[0].s());
BDE files = BDE::list();
SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
@ -569,7 +571,8 @@ BDE GetFilesXmlRpcMethod::process
e->_requestGroupMan->findDownloadResult(gid);
if(dr.isNull()) {
throw DL_ABORT_EX
(StringFormat("No file data is available for GID#%d", gid).str());
(StringFormat("No file data is available for GID#%s",
util::itos(gid).c_str()).str());
} else {
createFileEntry(files, dr->fileEntries.begin(), dr->fileEntries.end());
}
@ -591,12 +594,13 @@ BDE GetUrisXmlRpcMethod::process
throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED);
}
gid_t gid = util::parseInt(params[0].s());
gid_t gid = util::parseLLInt(params[0].s());
SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
if(group.isNull()) {
throw DL_ABORT_EX
(StringFormat("No URI data is available for GID#%d", gid).str());
(StringFormat("No URI data is available for GID#%s",
util::itos(gid).c_str()).str());
}
BDE uriList = BDE::list();
// TODO Current implementation just returns first FileEntry's URIs.
@ -617,12 +621,13 @@ BDE GetPeersXmlRpcMethod::process
throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED);
}
gid_t gid = util::parseInt(params[0].s());
gid_t gid = util::parseLLInt(params[0].s());
SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
if(group.isNull()) {
throw DL_ABORT_EX
(StringFormat("No peer data is available for GID#%d", gid).str());
(StringFormat("No peer data is available for GID#%s",
util::itos(gid).c_str()).str());
}
BDE peers = BDE::list();
BtObject btObject = e->getBtRegistry()->get(group->getGID());
@ -644,7 +649,7 @@ BDE TellStatusXmlRpcMethod::process
throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED);
}
gid_t gid = util::parseInt(params[0].s());
gid_t gid = util::parseLLInt(params[0].s());
SharedHandle<RequestGroup> group = e->_requestGroupMan->findRequestGroup(gid);
@ -656,7 +661,8 @@ BDE TellStatusXmlRpcMethod::process
e->_requestGroupMan->findDownloadResult(gid);
if(ds.isNull()) {
throw DL_ABORT_EX
(StringFormat("No such download for GID#%d", gid).str());
(StringFormat("No such download for GID#%s",
util::itos(gid).c_str()).str());
}
gatherStoppedDownload(entryDict, ds);
} else {
@ -728,12 +734,13 @@ BDE ChangeOptionXmlRpcMethod::process
if(params.empty() || !params[0].isString()) {
throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED);
}
gid_t gid = util::parseInt(params[0].s());
gid_t gid = util::parseLLInt(params[0].s());
SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
if(group.isNull()) {
throw DL_ABORT_EX
(StringFormat("Cannot change option for GID#%d", gid).str());
(StringFormat("Cannot change option for GID#%s",
util::itos(gid).c_str()).str());
}
SharedHandle<Option> option(new Option());
if(params.size() > 1 && params[1].isDict()) {
@ -823,12 +830,13 @@ BDE GetOptionXmlRpcMethod::process
if(params.empty() || !params[0].isString()) {
throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED);
}
gid_t gid = util::parseInt(params[0].s());
gid_t gid = util::parseLLInt(params[0].s());
SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
if(group.isNull()) {
throw DL_ABORT_EX
(StringFormat("Cannot get option for GID#%d", gid).str());
(StringFormat("Cannot get option for GID#%s",
util::itos(gid).c_str()).str());
}
BDE result = BDE::dict();
SharedHandle<Option> option = group->getOption();
@ -860,7 +868,7 @@ BDE ChangePositionXmlRpcMethod::process
!params[0].isString() || !params[1].isInteger() || !params[2].isString()) {
throw DL_ABORT_EX("Illegal argument.");
}
gid_t gid = util::parseInt(params[0].s());
gid_t gid = util::parseLLInt(params[0].s());
int pos = params[1].i();
const std::string& howStr = params[2].s();
RequestGroupMan::HOW how;
@ -896,10 +904,11 @@ BDE GetServersXmlRpcMethod::process
if(params.empty() || !params[0].isString()) {
throw DL_ABORT_EX("Bad request");
}
gid_t gid = util::parseInt(params[0].s());
gid_t gid = util::parseLLInt(params[0].s());
SharedHandle<RequestGroup> group = e->_requestGroupMan->findRequestGroup(gid);
if(group.isNull()) {
throw DL_ABORT_EX(StringFormat("No active download for GID#%d", gid).str());
throw DL_ABORT_EX(StringFormat("No active download for GID#%s",
util::itos(gid).c_str()).str());
}
SharedHandle<DownloadContext> dctx = group->getDownloadContext();
const std::vector<SharedHandle<FileEntry> >& files = dctx->getFileEntries();
@ -946,14 +955,15 @@ BDE ChangeUriXmlRpcMethod::process
bool posGiven = false;
getPosParam(params, 4, posGiven, pos);
gid_t gid = util::parseInt(params[0].s());
gid_t gid = util::parseLLInt(params[0].s());
size_t index = params[1].i()-1;
const BDE& deluris = params[2];
const BDE& adduris = params[3];
SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
if(group.isNull()) {
throw DL_ABORT_EX
(StringFormat("Cannot remove URIs from GID#%d", gid).str());
(StringFormat("Cannot remove URIs from GID#%s",
util::itos(gid).c_str()).str());
}
SharedHandle<DownloadContext> dctx = group->getDownloadContext();
const std::vector<SharedHandle<FileEntry> >& files = dctx->getFileEntries();

View File

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

View File

@ -668,7 +668,7 @@ void XmlRpcMethodTest::testGetVersion()
void XmlRpcMethodTest::testGatherStoppedDownload()
{
std::vector<SharedHandle<FileEntry> > fileEntries;
std::vector<int32_t> followedBy;
std::vector<gid_t> followedBy;
followedBy.push_back(3);
followedBy.push_back(4);
SharedHandle<DownloadResult> d
@ -767,7 +767,7 @@ void XmlRpcMethodTest::testChangePosition()
CPPUNIT_ASSERT_EQUAL(0, res._code);
CPPUNIT_ASSERT_EQUAL((int64_t)1, res._param.i());
CPPUNIT_ASSERT_EQUAL
((int32_t)1, _e->_requestGroupMan->getReservedGroups()[1]->getGID());
((gid_t)1, _e->_requestGroupMan->getReservedGroups()[1]->getGID());
}
void XmlRpcMethodTest::testChangePosition_fail()