mirror of https://github.com/aria2/aria2
2010-06-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Made public member variables of DownloadEngine private. Added accessor funcs.pull/1/head
parent
2dc4bf01ad
commit
7cd9b21937
|
@ -1,3 +1,8 @@
|
||||||
|
2010-06-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Made public member variables of DownloadEngine private. Added
|
||||||
|
accessor funcs.
|
||||||
|
|
||||||
2010-06-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-06-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Release 1.9.4
|
Release 1.9.4
|
||||||
|
|
|
@ -66,6 +66,8 @@
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
#include "NameResolver.h"
|
#include "NameResolver.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -134,7 +136,7 @@ bool AbstractCommand::execute() {
|
||||||
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||||
(cuid, fasterRequest, _fileEntry, _requestGroup, e);
|
(cuid, fasterRequest, _fileEntry, _requestGroup, e);
|
||||||
e->setNoWait(true);
|
e->setNoWait(true);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,13 +206,13 @@ bool AbstractCommand::execute() {
|
||||||
// timeout triggers ServerStat error state.
|
// timeout triggers ServerStat error state.
|
||||||
|
|
||||||
SharedHandle<ServerStat> ss =
|
SharedHandle<ServerStat> ss =
|
||||||
e->_requestGroupMan->getOrCreateServerStat(req->getHost(),
|
e->getRequestGroupMan()->getOrCreateServerStat(req->getHost(),
|
||||||
req->getProtocol());
|
req->getProtocol());
|
||||||
ss->setError();
|
ss->setError();
|
||||||
|
|
||||||
throw DL_RETRY_EX2(EX_TIME_OUT, downloadresultcode::TIME_OUT);
|
throw DL_RETRY_EX2(EX_TIME_OUT, downloadresultcode::TIME_OUT);
|
||||||
}
|
}
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch(DlAbortEx& err) {
|
} catch(DlAbortEx& err) {
|
||||||
|
@ -318,11 +320,11 @@ bool AbstractCommand::prepareForRetry(time_t wait) {
|
||||||
Command* command = new CreateRequestCommand(cuid, _requestGroup, e);
|
Command* command = new CreateRequestCommand(cuid, _requestGroup, e);
|
||||||
if(wait == 0) {
|
if(wait == 0) {
|
||||||
e->setNoWait(true);
|
e->setNoWait(true);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
} else {
|
} else {
|
||||||
SleepCommand* scom = new SleepCommand(cuid, e, _requestGroup,
|
SleepCommand* scom = new SleepCommand(cuid, e, _requestGroup,
|
||||||
command, wait);
|
command, wait);
|
||||||
e->commands.push_back(scom);
|
e->addCommand(scom);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -330,8 +332,8 @@ bool AbstractCommand::prepareForRetry(time_t wait) {
|
||||||
void AbstractCommand::onAbort() {
|
void AbstractCommand::onAbort() {
|
||||||
if(!req.isNull()) {
|
if(!req.isNull()) {
|
||||||
// TODO This might be a problem if the failure is caused by proxy.
|
// TODO This might be a problem if the failure is caused by proxy.
|
||||||
e->_requestGroupMan->getOrCreateServerStat(req->getHost(),
|
e->getRequestGroupMan()->getOrCreateServerStat(req->getHost(),
|
||||||
req->getProtocol())->setError();
|
req->getProtocol())->setError();
|
||||||
_fileEntry->removeIdenticalURI(req->getUri());
|
_fileEntry->removeIdenticalURI(req->getUri());
|
||||||
_fileEntry->removeRequest(req);
|
_fileEntry->removeRequest(req);
|
||||||
}
|
}
|
||||||
|
@ -610,7 +612,7 @@ bool AbstractCommand::asyncResolveHostname()
|
||||||
case AsyncNameResolver::STATUS_ERROR:
|
case AsyncNameResolver::STATUS_ERROR:
|
||||||
disableNameResolverCheck(_asyncNameResolver);
|
disableNameResolverCheck(_asyncNameResolver);
|
||||||
if(!isProxyRequest(req->getProtocol(), getOption())) {
|
if(!isProxyRequest(req->getProtocol(), getOption())) {
|
||||||
e->_requestGroupMan->getOrCreateServerStat
|
e->getRequestGroupMan()->getOrCreateServerStat
|
||||||
(req->getHost(), req->getProtocol())->setError();
|
(req->getHost(), req->getProtocol())->setError();
|
||||||
}
|
}
|
||||||
throw DL_ABORT_EX(StringFormat(MSG_NAME_RESOLUTION_FAILED,
|
throw DL_ABORT_EX(StringFormat(MSG_NAME_RESOLUTION_FAILED,
|
||||||
|
@ -671,7 +673,7 @@ std::string AbstractCommand::resolveHostname
|
||||||
{
|
{
|
||||||
NameResolver res;
|
NameResolver res;
|
||||||
res.setSocktype(SOCK_STREAM);
|
res.setSocktype(SOCK_STREAM);
|
||||||
if(e->option->getAsBool(PREF_DISABLE_IPV6)) {
|
if(e->getOption()->getAsBool(PREF_DISABLE_IPV6)) {
|
||||||
res.setFamily(AF_INET);
|
res.setFamily(AF_INET);
|
||||||
}
|
}
|
||||||
res.resolve(addrs, hostname);
|
res.resolve(addrs, hostname);
|
||||||
|
@ -737,14 +739,14 @@ bool AbstractCommand::checkIfConnectionEstablished
|
||||||
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||||
(cuid, req, _fileEntry, _requestGroup, e);
|
(cuid, req, _fileEntry, _requestGroup, e);
|
||||||
e->setNoWait(true);
|
e->setNoWait(true);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
e->removeCachedIPAddress(connectedHostname, connectedPort);
|
e->removeCachedIPAddress(connectedHostname, connectedPort);
|
||||||
// Don't set error if proxy server is used and its method is GET.
|
// Don't set error if proxy server is used and its method is GET.
|
||||||
if(resolveProxyMethod(req->getProtocol()) != V_GET ||
|
if(resolveProxyMethod(req->getProtocol()) != V_GET ||
|
||||||
!isProxyRequest(req->getProtocol(), getOption())) {
|
!isProxyRequest(req->getProtocol(), getOption())) {
|
||||||
e->_requestGroupMan->getOrCreateServerStat
|
e->getRequestGroupMan()->getOrCreateServerStat
|
||||||
(req->getHost(), req->getProtocol())->setError();
|
(req->getHost(), req->getProtocol())->setError();
|
||||||
}
|
}
|
||||||
throw DL_RETRY_EX
|
throw DL_RETRY_EX
|
||||||
|
|
|
@ -46,6 +46,10 @@
|
||||||
#include "AuthConfigFactory.h"
|
#include "AuthConfigFactory.h"
|
||||||
#include "AuthConfig.h"
|
#include "AuthConfig.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -86,11 +90,11 @@ bool AbstractProxyRequestCommand::executeInternal() {
|
||||||
httpConnection->sendPendingData();
|
httpConnection->sendPendingData();
|
||||||
}
|
}
|
||||||
if(httpConnection->sendBufferIsEmpty()) {
|
if(httpConnection->sendBufferIsEmpty()) {
|
||||||
e->commands.push_back(getNextCommand());
|
e->addCommand(getNextCommand());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
setWriteCheckSocket(socket);
|
setWriteCheckSocket(socket);
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,10 @@
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "HttpHeader.h"
|
#include "HttpHeader.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -66,13 +70,13 @@ bool AbstractProxyResponseCommand::executeInternal() {
|
||||||
SharedHandle<HttpResponse> httpResponse = httpConnection->receiveResponse();
|
SharedHandle<HttpResponse> httpResponse = httpConnection->receiveResponse();
|
||||||
if(httpResponse.isNull()) {
|
if(httpResponse.isNull()) {
|
||||||
// the server has not responded our request yet.
|
// the server has not responded our request yet.
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(httpResponse->getResponseStatus() != HttpHeader::S200) {
|
if(httpResponse->getResponseStatus() != HttpHeader::S200) {
|
||||||
throw DL_RETRY_EX(EX_PROXY_CONNECTION_FAILED);
|
throw DL_RETRY_EX(EX_PROXY_CONNECTION_FAILED);
|
||||||
}
|
}
|
||||||
e->commands.push_back(getNextCommand());
|
e->addCommand(getNextCommand());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,10 @@
|
||||||
#include "bittorrent_helper.h"
|
#include "bittorrent_helper.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -125,7 +129,7 @@ bool ActivePeerConnectionCommand::execute() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +144,7 @@ void ActivePeerConnectionCommand::connectToPeer(const SharedHandle<Peer>& peer)
|
||||||
_btRuntime);
|
_btRuntime);
|
||||||
command->setPeerStorage(_peerStorage);
|
command->setPeerStorage(_peerStorage);
|
||||||
command->setPieceStorage(_pieceStorage);
|
command->setPieceStorage(_pieceStorage);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
if(logger->info()) {
|
if(logger->info()) {
|
||||||
logger->info(MSG_CONNECTING_TO_PEER,
|
logger->info(MSG_CONNECTING_TO_PEER,
|
||||||
util::itos(cuid).c_str(), peer->ipaddr.c_str());
|
util::itos(cuid).c_str(), peer->ipaddr.c_str());
|
||||||
|
|
|
@ -36,6 +36,9 @@
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "RequestGroupMan.h"
|
#include "RequestGroupMan.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -46,14 +49,14 @@ AutoSaveCommand::~AutoSaveCommand() {}
|
||||||
|
|
||||||
void AutoSaveCommand::preProcess()
|
void AutoSaveCommand::preProcess()
|
||||||
{
|
{
|
||||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
||||||
_exit = true;
|
_exit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoSaveCommand::process()
|
void AutoSaveCommand::process()
|
||||||
{
|
{
|
||||||
_e->_requestGroupMan->save();
|
_e->getRequestGroupMan()->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,9 @@
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,10 @@
|
||||||
#include "LpdMessageDispatcher.h"
|
#include "LpdMessageDispatcher.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "SocketCore.h"
|
#include "SocketCore.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -160,12 +164,12 @@ void BtSetup::setup(std::vector<Command*>& commands,
|
||||||
}
|
}
|
||||||
if(PeerListenCommand::getNumInstance() == 0) {
|
if(PeerListenCommand::getNumInstance() == 0) {
|
||||||
PeerListenCommand* listenCommand = PeerListenCommand::getInstance(e);
|
PeerListenCommand* listenCommand = PeerListenCommand::getInstance(e);
|
||||||
IntSequence seq = util::parseIntRange(e->option->get(PREF_LISTEN_PORT));
|
IntSequence seq =util::parseIntRange(e->getOption()->get(PREF_LISTEN_PORT));
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
if(listenCommand->bindPort(port, seq)) {
|
if(listenCommand->bindPort(port, seq)) {
|
||||||
btRuntime->setListenPort(port);
|
btRuntime->setListenPort(port);
|
||||||
// Add command to DownloadEngine directly.
|
// Add command to DownloadEngine directly.
|
||||||
e->commands.push_back(listenCommand);
|
e->addCommand(listenCommand);
|
||||||
} else {
|
} else {
|
||||||
delete listenCommand;
|
delete listenCommand;
|
||||||
throw DL_ABORT_EX(_("Errors occurred while binding port.\n"));
|
throw DL_ABORT_EX(_("Errors occurred while binding port.\n"));
|
||||||
|
@ -181,7 +185,8 @@ void BtSetup::setup(std::vector<Command*>& commands,
|
||||||
SharedHandle<LpdMessageReceiver> receiver
|
SharedHandle<LpdMessageReceiver> receiver
|
||||||
(new LpdMessageReceiver(LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT));
|
(new LpdMessageReceiver(LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT));
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
const std::string& lpdInterface = e->option->get(PREF_BT_LPD_INTERFACE);
|
const std::string& lpdInterface =
|
||||||
|
e->getOption()->get(PREF_BT_LPD_INTERFACE);
|
||||||
if(lpdInterface.empty()) {
|
if(lpdInterface.empty()) {
|
||||||
if(receiver->init("")) {
|
if(receiver->init("")) {
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
@ -206,7 +211,7 @@ void BtSetup::setup(std::vector<Command*>& commands,
|
||||||
receiver->getLocalAddress().c_str());
|
receiver->getLocalAddress().c_str());
|
||||||
LpdReceiveMessageCommand* cmd =
|
LpdReceiveMessageCommand* cmd =
|
||||||
LpdReceiveMessageCommand::getInstance(e, receiver);
|
LpdReceiveMessageCommand::getInstance(e, receiver);
|
||||||
e->commands.push_back(cmd);
|
e->addCommand(cmd);
|
||||||
} else {
|
} else {
|
||||||
_logger->info("LpdMessageReceiver not initialized.");
|
_logger->info("LpdMessageReceiver not initialized.");
|
||||||
}
|
}
|
||||||
|
@ -227,7 +232,7 @@ void BtSetup::setup(std::vector<Command*>& commands,
|
||||||
LpdDispatchMessageCommand* cmd =
|
LpdDispatchMessageCommand* cmd =
|
||||||
new LpdDispatchMessageCommand(e->newCUID(), dispatcher, e);
|
new LpdDispatchMessageCommand(e->newCUID(), dispatcher, e);
|
||||||
cmd->setBtRuntime(btRuntime);
|
cmd->setBtRuntime(btRuntime);
|
||||||
e->commands.push_back(cmd);
|
e->addCommand(cmd);
|
||||||
} else {
|
} else {
|
||||||
_logger->info("LpdMessageDispatcher not initialized.");
|
_logger->info("LpdMessageDispatcher not initialized.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,9 @@
|
||||||
#include "a2functional.h"
|
#include "a2functional.h"
|
||||||
#include "RecoverableException.h"
|
#include "RecoverableException.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -58,12 +61,12 @@ CheckIntegrityCommand::~CheckIntegrityCommand() {}
|
||||||
bool CheckIntegrityCommand::executeInternal()
|
bool CheckIntegrityCommand::executeInternal()
|
||||||
{
|
{
|
||||||
if(_requestGroup->isHaltRequested()) {
|
if(_requestGroup->isHaltRequested()) {
|
||||||
_e->_checkIntegrityMan->dropPickedEntry();
|
_e->getCheckIntegrityMan()->dropPickedEntry();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
_entry->validateChunk();
|
_entry->validateChunk();
|
||||||
if(_entry->finished()) {
|
if(_entry->finished()) {
|
||||||
_e->_checkIntegrityMan->dropPickedEntry();
|
_e->getCheckIntegrityMan()->dropPickedEntry();
|
||||||
// Enable control file saving here. See also
|
// Enable control file saving here. See also
|
||||||
// RequestGroup::processCheckIntegrityEntry() to know why this is
|
// RequestGroup::processCheckIntegrityEntry() to know why this is
|
||||||
// needed.
|
// needed.
|
||||||
|
@ -94,14 +97,14 @@ bool CheckIntegrityCommand::executeInternal()
|
||||||
_e->setNoWait(true);
|
_e->setNoWait(true);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
_e->commands.push_back(this);
|
_e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckIntegrityCommand::handleException(Exception& e)
|
bool CheckIntegrityCommand::handleException(Exception& e)
|
||||||
{
|
{
|
||||||
_e->_checkIntegrityMan->dropPickedEntry();
|
_e->getCheckIntegrityMan()->dropPickedEntry();
|
||||||
logger->error(MSG_FILE_VALIDATION_FAILURE, e, util::itos(cuid).c_str());
|
logger->error(MSG_FILE_VALIDATION_FAILURE, e, util::itos(cuid).c_str());
|
||||||
logger->error(MSG_DOWNLOAD_NOT_COMPLETE,
|
logger->error(MSG_DOWNLOAD_NOT_COMPLETE,
|
||||||
util::itos(cuid).c_str(),
|
util::itos(cuid).c_str(),
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -91,7 +93,7 @@ void CheckIntegrityEntry::proceedFileAllocation
|
||||||
DownloadEngine* e)
|
DownloadEngine* e)
|
||||||
{
|
{
|
||||||
if(_requestGroup->needsFileAllocation()) {
|
if(_requestGroup->needsFileAllocation()) {
|
||||||
e->_fileAllocationMan->pushEntry(entry);
|
e->getFileAllocationMan()->pushEntry(entry);
|
||||||
} else {
|
} else {
|
||||||
entry->prepareForNextAction(commands, e);
|
entry->prepareForNextAction(commands, e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,9 @@
|
||||||
#include "IteratableChecksumValidator.h"
|
#include "IteratableChecksumValidator.h"
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "PieceStorage.h"
|
#include "PieceStorage.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
# include "bittorrent_helper.h"
|
# include "bittorrent_helper.h"
|
||||||
# include "Peer.h"
|
# include "Peer.h"
|
||||||
|
@ -242,37 +243,38 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
|
||||||
std::cout << '\r' << std::setfill(' ') << std::setw(cols) << ' ' << '\r';
|
std::cout << '\r' << std::setfill(' ') << std::setw(cols) << ' ' << '\r';
|
||||||
}
|
}
|
||||||
std::ostringstream o;
|
std::ostringstream o;
|
||||||
if(e->_requestGroupMan->countRequestGroup() > 0) {
|
if(e->getRequestGroupMan()->countRequestGroup() > 0) {
|
||||||
if((_summaryInterval > 0) &&
|
if((_summaryInterval > 0) &&
|
||||||
_lastSummaryNotified.difference(global::wallclock) >= _summaryInterval) {
|
_lastSummaryNotified.difference(global::wallclock) >= _summaryInterval) {
|
||||||
_lastSummaryNotified = global::wallclock;
|
_lastSummaryNotified = global::wallclock;
|
||||||
printProgressSummary(e->_requestGroupMan->getRequestGroups(), cols, e,
|
printProgressSummary(e->getRequestGroupMan()->getRequestGroups(), cols, e,
|
||||||
sizeFormatter);
|
sizeFormatter);
|
||||||
std::cout << "\n";
|
std::cout << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<RequestGroup> firstRequestGroup =
|
SharedHandle<RequestGroup> firstRequestGroup =
|
||||||
e->_requestGroupMan->getRequestGroup(0);
|
e->getRequestGroupMan()->getRequestGroup(0);
|
||||||
|
|
||||||
printProgress(o, firstRequestGroup, e, sizeFormatter);
|
printProgress(o, firstRequestGroup, e, sizeFormatter);
|
||||||
|
|
||||||
if(e->_requestGroupMan->countRequestGroup() > 1) {
|
if(e->getRequestGroupMan()->countRequestGroup() > 1) {
|
||||||
o << "("
|
o << "("
|
||||||
<< e->_requestGroupMan->countRequestGroup()-1
|
<< e->getRequestGroupMan()->countRequestGroup()-1
|
||||||
<< "more...)";
|
<< "more...)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e->_requestGroupMan->countRequestGroup() > 1 &&
|
if(e->getRequestGroupMan()->countRequestGroup() > 1 &&
|
||||||
!e->_requestGroupMan->downloadFinished()) {
|
!e->getRequestGroupMan()->downloadFinished()) {
|
||||||
TransferStat stat = e->_requestGroupMan->calculateStat();
|
TransferStat stat = e->getRequestGroupMan()->calculateStat();
|
||||||
o << " "
|
o << " "
|
||||||
<< "[TOTAL SPD:"
|
<< "[TOTAL SPD:"
|
||||||
<< sizeFormatter(stat.getDownloadSpeed()) << "Bs" << "]";
|
<< sizeFormatter(stat.getDownloadSpeed()) << "Bs" << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SharedHandle<FileAllocationEntry> entry=e->_fileAllocationMan->getPickedEntry();
|
SharedHandle<FileAllocationEntry> entry =
|
||||||
|
e->getFileAllocationMan()->getPickedEntry();
|
||||||
if(!entry.isNull()) {
|
if(!entry.isNull()) {
|
||||||
o << " "
|
o << " "
|
||||||
<< "[FileAlloc:"
|
<< "[FileAlloc:"
|
||||||
|
@ -290,9 +292,9 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
|
||||||
}
|
}
|
||||||
o << "%)"
|
o << "%)"
|
||||||
<< "]";
|
<< "]";
|
||||||
if(e->_fileAllocationMan->hasNext()) {
|
if(e->getFileAllocationMan()->hasNext()) {
|
||||||
o << "("
|
o << "("
|
||||||
<< e->_fileAllocationMan->countEntryInQueue()
|
<< e->getFileAllocationMan()->countEntryInQueue()
|
||||||
<< "waiting...)";
|
<< "waiting...)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,7 +302,7 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
{
|
{
|
||||||
SharedHandle<CheckIntegrityEntry> entry =
|
SharedHandle<CheckIntegrityEntry> entry =
|
||||||
e->_checkIntegrityMan->getPickedEntry();
|
e->getCheckIntegrityMan()->getPickedEntry();
|
||||||
if(!entry.isNull()) {
|
if(!entry.isNull()) {
|
||||||
o << " "
|
o << " "
|
||||||
<< "[Checksum:"
|
<< "[Checksum:"
|
||||||
|
@ -314,9 +316,9 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
|
||||||
<< 100*entry->getCurrentLength()/entry->getTotalLength()
|
<< 100*entry->getCurrentLength()/entry->getTotalLength()
|
||||||
<< "%)"
|
<< "%)"
|
||||||
<< "]";
|
<< "]";
|
||||||
if(e->_checkIntegrityMan->hasNext()) {
|
if(e->getCheckIntegrityMan()->hasNext()) {
|
||||||
o << "("
|
o << "("
|
||||||
<< e->_checkIntegrityMan->countEntryInQueue()
|
<< e->getCheckIntegrityMan()->countEntryInQueue()
|
||||||
<< "waiting...)";
|
<< "waiting...)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,10 @@
|
||||||
#include "SleepCommand.h"
|
#include "SleepCommand.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -95,7 +99,7 @@ bool CreateRequestCommand::executeInternal()
|
||||||
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||||
(cuid, req, _fileEntry, _requestGroup, e);
|
(cuid, req, _fileEntry, _requestGroup, e);
|
||||||
e->setNoWait(true);
|
e->setNoWait(true);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +121,7 @@ bool CreateRequestCommand::prepareForRetry(time_t wait)
|
||||||
util::itos(cuid).c_str());
|
util::itos(cuid).c_str());
|
||||||
}
|
}
|
||||||
SleepCommand* scom = new SleepCommand(cuid, e, _requestGroup, this, wait);
|
SleepCommand* scom = new SleepCommand(cuid, e, _requestGroup, this, wait);
|
||||||
e->commands.push_back(scom);
|
e->addCommand(scom);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,9 @@
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "DlAbortEx.h"
|
#include "DlAbortEx.h"
|
||||||
#include "StringFormat.h"
|
#include "StringFormat.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -65,7 +68,7 @@ DHTAutoSaveCommand::~DHTAutoSaveCommand() {}
|
||||||
|
|
||||||
void DHTAutoSaveCommand::preProcess()
|
void DHTAutoSaveCommand::preProcess()
|
||||||
{
|
{
|
||||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
||||||
save();
|
save();
|
||||||
_exit = true;
|
_exit = true;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +81,7 @@ void DHTAutoSaveCommand::process()
|
||||||
|
|
||||||
void DHTAutoSaveCommand::save()
|
void DHTAutoSaveCommand::save()
|
||||||
{
|
{
|
||||||
std::string dhtFile = _e->option->get(PREF_DHT_FILE_PATH);
|
std::string dhtFile = _e->getOption()->get(PREF_DHT_FILE_PATH);
|
||||||
logger->info("Saving DHT routing table to %s.", dhtFile.c_str());
|
logger->info("Saving DHT routing table to %s.", dhtFile.c_str());
|
||||||
|
|
||||||
std::string tempFile = dhtFile;
|
std::string tempFile = dhtFile;
|
||||||
|
|
|
@ -40,6 +40,9 @@
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "RequestGroupMan.h"
|
#include "RequestGroupMan.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -51,7 +54,7 @@ DHTBucketRefreshCommand::~DHTBucketRefreshCommand() {}
|
||||||
|
|
||||||
void DHTBucketRefreshCommand::preProcess()
|
void DHTBucketRefreshCommand::preProcess()
|
||||||
{
|
{
|
||||||
_exit = _e->_requestGroupMan->downloadFinished() || _e->isHaltRequested();
|
_exit = _e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DHTBucketRefreshCommand::process()
|
void DHTBucketRefreshCommand::process()
|
||||||
|
|
|
@ -52,6 +52,9 @@
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "StringFormat.h"
|
#include "StringFormat.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -73,7 +76,7 @@ DHTEntryPointNameResolveCommand::~DHTEntryPointNameResolveCommand()
|
||||||
|
|
||||||
bool DHTEntryPointNameResolveCommand::execute()
|
bool DHTEntryPointNameResolveCommand::execute()
|
||||||
{
|
{
|
||||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_ASYNC_DNS
|
#ifdef ENABLE_ASYNC_DNS
|
||||||
|
@ -83,7 +86,7 @@ bool DHTEntryPointNameResolveCommand::execute()
|
||||||
#endif // ENABLE_ASYNC_DNS
|
#endif // ENABLE_ASYNC_DNS
|
||||||
try {
|
try {
|
||||||
#ifdef ENABLE_ASYNC_DNS
|
#ifdef ENABLE_ASYNC_DNS
|
||||||
if(_e->option->getAsBool(PREF_ASYNC_DNS)) {
|
if(_e->getOption()->getAsBool(PREF_ASYNC_DNS)) {
|
||||||
while(!_entryPoints.empty()) {
|
while(!_entryPoints.empty()) {
|
||||||
std::string hostname = _entryPoints.front().first;
|
std::string hostname = _entryPoints.front().first;
|
||||||
try {
|
try {
|
||||||
|
@ -94,7 +97,7 @@ bool DHTEntryPointNameResolveCommand::execute()
|
||||||
_resolvedEntryPoints.push_back(p);
|
_resolvedEntryPoints.push_back(p);
|
||||||
addPingTask(p);
|
addPingTask(p);
|
||||||
} else {
|
} else {
|
||||||
_e->commands.push_back(this);
|
_e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch(RecoverableException& e) {
|
} catch(RecoverableException& e) {
|
||||||
|
|
|
@ -47,6 +47,10 @@
|
||||||
#include "bittorrent_helper.h"
|
#include "bittorrent_helper.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -94,7 +98,7 @@ bool DHTGetPeersCommand::execute()
|
||||||
_task.reset();
|
_task.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
_e->commands.push_back(this);
|
_e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,9 @@
|
||||||
#include "DHTMessageCallback.h"
|
#include "DHTMessageCallback.h"
|
||||||
#include "DHTNode.h"
|
#include "DHTNode.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -71,7 +74,7 @@ void DHTInteractionCommand::disableReadCheckSocket(const SocketHandle& socket)
|
||||||
|
|
||||||
bool DHTInteractionCommand::execute()
|
bool DHTInteractionCommand::execute()
|
||||||
{
|
{
|
||||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +92,7 @@ bool DHTInteractionCommand::execute()
|
||||||
} catch(RecoverableException& e) {
|
} catch(RecoverableException& e) {
|
||||||
logger->error(EX_EXCEPTION_CAUGHT, e);
|
logger->error(EX_EXCEPTION_CAUGHT, e);
|
||||||
}
|
}
|
||||||
_e->commands.push_back(this);
|
_e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,9 @@
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -51,7 +54,7 @@ DHTPeerAnnounceCommand::~DHTPeerAnnounceCommand() {}
|
||||||
|
|
||||||
void DHTPeerAnnounceCommand::preProcess()
|
void DHTPeerAnnounceCommand::preProcess()
|
||||||
{
|
{
|
||||||
_exit = _e->_requestGroupMan->downloadFinished() || _e->isHaltRequested();
|
_exit = _e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DHTPeerAnnounceCommand::process()
|
void DHTPeerAnnounceCommand::process()
|
||||||
|
|
|
@ -71,6 +71,11 @@
|
||||||
#include "a2functional.h"
|
#include "a2functional.h"
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -93,7 +98,7 @@ void DHTSetup::setup(std::vector<Command*>& commands, DownloadEngine* e)
|
||||||
SharedHandle<DHTNode> localNode;
|
SharedHandle<DHTNode> localNode;
|
||||||
|
|
||||||
DHTRoutingTableDeserializer deserializer;
|
DHTRoutingTableDeserializer deserializer;
|
||||||
std::string dhtFile = e->option->get(PREF_DHT_FILE_PATH);
|
std::string dhtFile = e->getOption()->get(PREF_DHT_FILE_PATH);
|
||||||
try {
|
try {
|
||||||
std::ifstream in(dhtFile.c_str(), std::ios::binary);
|
std::ifstream in(dhtFile.c_str(), std::ios::binary);
|
||||||
if(!in) {
|
if(!in) {
|
||||||
|
@ -112,7 +117,7 @@ void DHTSetup::setup(std::vector<Command*>& commands, DownloadEngine* e)
|
||||||
SharedHandle<DHTConnectionImpl> connection(new DHTConnectionImpl());
|
SharedHandle<DHTConnectionImpl> connection(new DHTConnectionImpl());
|
||||||
{
|
{
|
||||||
IntSequence seq =
|
IntSequence seq =
|
||||||
util::parseIntRange(e->option->get(PREF_DHT_LISTEN_PORT));
|
util::parseIntRange(e->getOption()->get(PREF_DHT_LISTEN_PORT));
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
if(!connection->bind(port, seq)) {
|
if(!connection->bind(port, seq)) {
|
||||||
throw DL_ABORT_EX("Error occurred while binding port for DHT");
|
throw DL_ABORT_EX("Error occurred while binding port for DHT");
|
||||||
|
@ -141,7 +146,7 @@ void DHTSetup::setup(std::vector<Command*>& commands, DownloadEngine* e)
|
||||||
|
|
||||||
SharedHandle<DHTTokenTracker> tokenTracker(new DHTTokenTracker());
|
SharedHandle<DHTTokenTracker> tokenTracker(new DHTTokenTracker());
|
||||||
|
|
||||||
const time_t messageTimeout = e->option->getAsInt(PREF_DHT_MESSAGE_TIMEOUT);
|
const time_t messageTimeout = e->getOption()->getAsInt(PREF_DHT_MESSAGE_TIMEOUT);
|
||||||
// wiring up
|
// wiring up
|
||||||
tracker->setRoutingTable(routingTable);
|
tracker->setRoutingTable(routingTable);
|
||||||
tracker->setMessageFactory(factory);
|
tracker->setMessageFactory(factory);
|
||||||
|
@ -199,11 +204,11 @@ void DHTSetup::setup(std::vector<Command*>& commands, DownloadEngine* e)
|
||||||
taskQueue->addPeriodicTask1(task);
|
taskQueue->addPeriodicTask1(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!e->option->get(PREF_DHT_ENTRY_POINT_HOST).empty()) {
|
if(!e->getOption()->get(PREF_DHT_ENTRY_POINT_HOST).empty()) {
|
||||||
{
|
{
|
||||||
std::pair<std::string, uint16_t> addr
|
std::pair<std::string, uint16_t> addr
|
||||||
(e->option->get(PREF_DHT_ENTRY_POINT_HOST),
|
(e->getOption()->get(PREF_DHT_ENTRY_POINT_HOST),
|
||||||
e->option->getAsInt(PREF_DHT_ENTRY_POINT_PORT));
|
e->getOption()->getAsInt(PREF_DHT_ENTRY_POINT_PORT));
|
||||||
std::vector<std::pair<std::string, uint16_t> > entryPoints;
|
std::vector<std::pair<std::string, uint16_t> > entryPoints;
|
||||||
entryPoints.push_back(addr);
|
entryPoints.push_back(addr);
|
||||||
DHTEntryPointNameResolveCommand* command =
|
DHTEntryPointNameResolveCommand* command =
|
||||||
|
|
|
@ -40,6 +40,9 @@
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -52,7 +55,7 @@ DHTTokenUpdateCommand::~DHTTokenUpdateCommand() {}
|
||||||
|
|
||||||
void DHTTokenUpdateCommand::preProcess()
|
void DHTTokenUpdateCommand::preProcess()
|
||||||
{
|
{
|
||||||
_exit = _e->_requestGroupMan->downloadFinished() || _e->isHaltRequested();
|
_exit = _e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DHTTokenUpdateCommand::process()
|
void DHTTokenUpdateCommand::process()
|
||||||
|
|
|
@ -59,6 +59,8 @@
|
||||||
#include "Decoder.h"
|
#include "Decoder.h"
|
||||||
#include "RequestGroupMan.h"
|
#include "RequestGroupMan.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
# include "MessageDigestHelper.h"
|
# include "MessageDigestHelper.h"
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
@ -106,9 +108,9 @@ DownloadCommand::~DownloadCommand() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DownloadCommand::executeInternal() {
|
bool DownloadCommand::executeInternal() {
|
||||||
if(e->_requestGroupMan->doesOverallDownloadSpeedExceed() ||
|
if(e->getRequestGroupMan()->doesOverallDownloadSpeedExceed() ||
|
||||||
_requestGroup->doesDownloadSpeedExceed()) {
|
_requestGroup->doesDownloadSpeedExceed()) {
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
disableReadCheckSocket();
|
disableReadCheckSocket();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +250,7 @@ bool DownloadCommand::executeInternal() {
|
||||||
} else {
|
} else {
|
||||||
checkLowestDownloadSpeed();
|
checkLowestDownloadSpeed();
|
||||||
setWriteCheckSocketIf(socket, socket->wantWrite());
|
setWriteCheckSocketIf(socket, socket->wantWrite());
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,7 +294,7 @@ bool DownloadCommand::prepareForNextSegment() {
|
||||||
if(entry->isValidationReady()) {
|
if(entry->isValidationReady()) {
|
||||||
entry->initValidator();
|
entry->initValidator();
|
||||||
// TODO do we need cuttrailinggarbage here?
|
// TODO do we need cuttrailinggarbage here?
|
||||||
e->_checkIntegrityMan->pushEntry(entry);
|
e->getCheckIntegrityMan()->pushEntry(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Following 2lines are needed for DownloadEngine to detect
|
// Following 2lines are needed for DownloadEngine to detect
|
||||||
|
@ -316,7 +318,7 @@ bool DownloadCommand::prepareForNextSegment() {
|
||||||
if(nextSegment.isNull()) {
|
if(nextSegment.isNull()) {
|
||||||
return prepareForRetry(0);
|
return prepareForRetry(0);
|
||||||
} else {
|
} else {
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -111,8 +111,8 @@ DownloadEngine::~DownloadEngine() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadEngine::cleanQueue() {
|
void DownloadEngine::cleanQueue() {
|
||||||
std::for_each(commands.begin(), commands.end(), Deleter());
|
std::for_each(_commands.begin(), _commands.end(), Deleter());
|
||||||
commands.clear();
|
_commands.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void executeCommand(std::deque<Command*>& commands,
|
static void executeCommand(std::deque<Command*>& commands,
|
||||||
|
@ -141,18 +141,18 @@ void DownloadEngine::run()
|
||||||
{
|
{
|
||||||
Timer cp;
|
Timer cp;
|
||||||
cp.reset(0);
|
cp.reset(0);
|
||||||
while(!commands.empty() || !_routineCommands.empty()) {
|
while(!_commands.empty() || !_routineCommands.empty()) {
|
||||||
global::wallclock.reset();
|
global::wallclock.reset();
|
||||||
if(cp.difference(global::wallclock) >= _refreshInterval) {
|
if(cp.difference(global::wallclock) >= _refreshInterval) {
|
||||||
_refreshInterval = DEFAULT_REFRESH_INTERVAL;
|
_refreshInterval = DEFAULT_REFRESH_INTERVAL;
|
||||||
cp = global::wallclock;
|
cp = global::wallclock;
|
||||||
executeCommand(commands, Command::STATUS_ALL);
|
executeCommand(_commands, Command::STATUS_ALL);
|
||||||
} else {
|
} else {
|
||||||
executeCommand(commands, Command::STATUS_ACTIVE);
|
executeCommand(_commands, Command::STATUS_ACTIVE);
|
||||||
}
|
}
|
||||||
executeCommand(_routineCommands, Command::STATUS_ALL);
|
executeCommand(_routineCommands, Command::STATUS_ALL);
|
||||||
afterEachIteration();
|
afterEachIteration();
|
||||||
if(!commands.empty()) {
|
if(!_commands.empty()) {
|
||||||
waitData();
|
waitData();
|
||||||
}
|
}
|
||||||
_noWait = false;
|
_noWait = false;
|
||||||
|
@ -250,11 +250,6 @@ void DownloadEngine::setStatCalc(const StatCalcHandle& statCalc)
|
||||||
_statCalc = statCalc;
|
_statCalc = statCalc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadEngine::addCommand(const std::vector<Command*>& commands)
|
|
||||||
{
|
|
||||||
this->commands.insert(this->commands.end(), commands.begin(), commands.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ENABLE_ASYNC_DNS
|
#ifdef ENABLE_ASYNC_DNS
|
||||||
bool DownloadEngine::addNameResolverCheck
|
bool DownloadEngine::addNameResolverCheck
|
||||||
(const SharedHandle<AsyncNameResolver>& resolver, Command* command)
|
(const SharedHandle<AsyncNameResolver>& resolver, Command* command)
|
||||||
|
|
|
@ -154,16 +154,16 @@ private:
|
||||||
|
|
||||||
std::multimap<std::string, SocketPoolEntry>::iterator
|
std::multimap<std::string, SocketPoolEntry>::iterator
|
||||||
findSocketPoolEntry(const std::string& key);
|
findSocketPoolEntry(const std::string& key);
|
||||||
public:
|
|
||||||
std::deque<Command*> commands;
|
std::deque<Command*> _commands;
|
||||||
SharedHandle<RequestGroupMan> _requestGroupMan;
|
SharedHandle<RequestGroupMan> _requestGroupMan;
|
||||||
SharedHandle<FileAllocationMan> _fileAllocationMan;
|
SharedHandle<FileAllocationMan> _fileAllocationMan;
|
||||||
SharedHandle<CheckIntegrityMan> _checkIntegrityMan;
|
SharedHandle<CheckIntegrityMan> _checkIntegrityMan;
|
||||||
Option* option;
|
Option* _option;
|
||||||
|
public:
|
||||||
DownloadEngine(const SharedHandle<EventPoll>& eventPoll);
|
DownloadEngine(const SharedHandle<EventPoll>& eventPoll);
|
||||||
|
|
||||||
virtual ~DownloadEngine();
|
~DownloadEngine();
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
|
@ -186,7 +186,55 @@ public:
|
||||||
Command* command);
|
Command* command);
|
||||||
#endif // ENABLE_ASYNC_DNS
|
#endif // ENABLE_ASYNC_DNS
|
||||||
|
|
||||||
void addCommand(const std::vector<Command*>& commands);
|
void addCommand(const std::vector<Command*>& commands)
|
||||||
|
{
|
||||||
|
_commands.insert(_commands.end(), commands.begin(), commands.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
void addCommand(Command* command)
|
||||||
|
{
|
||||||
|
_commands.push_back(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
const SharedHandle<RequestGroupMan>& getRequestGroupMan() const
|
||||||
|
{
|
||||||
|
return _requestGroupMan;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setRequestGroupMan(const SharedHandle<RequestGroupMan>& rgman)
|
||||||
|
{
|
||||||
|
_requestGroupMan = rgman;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SharedHandle<FileAllocationMan>& getFileAllocationMan() const
|
||||||
|
{
|
||||||
|
return _fileAllocationMan;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFileAllocationMan(const SharedHandle<FileAllocationMan>& faman)
|
||||||
|
{
|
||||||
|
_fileAllocationMan = faman;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SharedHandle<CheckIntegrityMan>& getCheckIntegrityMan() const
|
||||||
|
{
|
||||||
|
return _checkIntegrityMan;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setCheckIntegrityMan(const SharedHandle<CheckIntegrityMan>& ciman)
|
||||||
|
{
|
||||||
|
_checkIntegrityMan = ciman;
|
||||||
|
}
|
||||||
|
|
||||||
|
Option* getOption() const
|
||||||
|
{
|
||||||
|
return _option;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setOption(Option* op)
|
||||||
|
{
|
||||||
|
_option = op;
|
||||||
|
}
|
||||||
|
|
||||||
void setStatCalc(const SharedHandle<StatCalc>& statCalc);
|
void setStatCalc(const SharedHandle<StatCalc>& statCalc);
|
||||||
|
|
||||||
|
|
|
@ -134,22 +134,24 @@ DownloadEngineFactory::newDownloadEngine
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
DownloadEngineHandle e(new DownloadEngine(eventPoll));
|
DownloadEngineHandle e(new DownloadEngine(eventPoll));
|
||||||
e->option = op;
|
e->setOption(op);
|
||||||
|
|
||||||
RequestGroupManHandle
|
RequestGroupManHandle
|
||||||
requestGroupMan(new RequestGroupMan(requestGroups, MAX_CONCURRENT_DOWNLOADS,
|
requestGroupMan(new RequestGroupMan(requestGroups, MAX_CONCURRENT_DOWNLOADS,
|
||||||
op));
|
op));
|
||||||
e->_requestGroupMan = requestGroupMan;
|
e->setRequestGroupMan(requestGroupMan);
|
||||||
e->_fileAllocationMan.reset(new FileAllocationMan());
|
e->setFileAllocationMan
|
||||||
|
(SharedHandle<FileAllocationMan>(new FileAllocationMan()));
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
e->_checkIntegrityMan.reset(new CheckIntegrityMan());
|
e->setCheckIntegrityMan
|
||||||
|
(SharedHandle<CheckIntegrityMan>(new CheckIntegrityMan()));
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
e->addRoutineCommand(new FillRequestGroupCommand(e->newCUID(), e.get()));
|
e->addRoutineCommand(new FillRequestGroupCommand(e->newCUID(), e.get()));
|
||||||
e->addRoutineCommand(new FileAllocationDispatcherCommand
|
e->addRoutineCommand(new FileAllocationDispatcherCommand
|
||||||
(e->newCUID(), e->_fileAllocationMan, e.get()));
|
(e->newCUID(), e->getFileAllocationMan(), e.get()));
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
e->addRoutineCommand(new CheckIntegrityDispatcherCommand
|
e->addRoutineCommand(new CheckIntegrityDispatcherCommand
|
||||||
(e->newCUID(), e->_checkIntegrityMan, e.get()));
|
(e->newCUID(), e->getCheckIntegrityMan(), e.get()));
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) {
|
if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) {
|
||||||
|
|
|
@ -46,6 +46,9 @@
|
||||||
#include "a2functional.h"
|
#include "a2functional.h"
|
||||||
#include "RecoverableException.h"
|
#include "RecoverableException.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -60,7 +63,7 @@ FileAllocationCommand::~FileAllocationCommand() {}
|
||||||
bool FileAllocationCommand::executeInternal()
|
bool FileAllocationCommand::executeInternal()
|
||||||
{
|
{
|
||||||
if(_requestGroup->isHaltRequested()) {
|
if(_requestGroup->isHaltRequested()) {
|
||||||
_e->_fileAllocationMan->dropPickedEntry();
|
_e->getFileAllocationMan()->dropPickedEntry();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
_fileAllocationEntry->allocateChunk();
|
_fileAllocationEntry->allocateChunk();
|
||||||
|
@ -70,7 +73,7 @@ bool FileAllocationCommand::executeInternal()
|
||||||
_timer.difference(global::wallclock),
|
_timer.difference(global::wallclock),
|
||||||
util::itos(_requestGroup->getTotalLength(), true).c_str());
|
util::itos(_requestGroup->getTotalLength(), true).c_str());
|
||||||
}
|
}
|
||||||
_e->_fileAllocationMan->dropPickedEntry();
|
_e->getFileAllocationMan()->dropPickedEntry();
|
||||||
|
|
||||||
std::vector<Command*> commands;
|
std::vector<Command*> commands;
|
||||||
try {
|
try {
|
||||||
|
@ -83,14 +86,14 @@ bool FileAllocationCommand::executeInternal()
|
||||||
_e->setNoWait(true);
|
_e->setNoWait(true);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
_e->commands.push_back(this);
|
_e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileAllocationCommand::handleException(Exception& e)
|
bool FileAllocationCommand::handleException(Exception& e)
|
||||||
{
|
{
|
||||||
_e->_fileAllocationMan->dropPickedEntry();
|
_e->getFileAllocationMan()->dropPickedEntry();
|
||||||
logger->error(MSG_FILE_ALLOCATION_FAILURE, e, util::itos(cuid).c_str());
|
logger->error(MSG_FILE_ALLOCATION_FAILURE, e, util::itos(cuid).c_str());
|
||||||
logger->error(MSG_DOWNLOAD_NOT_COMPLETE, util::itos(cuid).c_str(),
|
logger->error(MSG_DOWNLOAD_NOT_COMPLETE, util::itos(cuid).c_str(),
|
||||||
_requestGroup->getDownloadContext()->getBasePath().c_str());
|
_requestGroup->getDownloadContext()->getBasePath().c_str());
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,9 @@
|
||||||
#include "PieceStorage.h"
|
#include "PieceStorage.h"
|
||||||
#include "DiskAdaptor.h"
|
#include "DiskAdaptor.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "ServerStatMan.h"
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -59,7 +61,7 @@ bool FillRequestGroupCommand::execute()
|
||||||
if(_e->isHaltRequested()) {
|
if(_e->isHaltRequested()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
SharedHandle<RequestGroupMan> rgman = _e->_requestGroupMan;
|
SharedHandle<RequestGroupMan> rgman = _e->getRequestGroupMan();
|
||||||
if(rgman->queueCheckRequested()) {
|
if(rgman->queueCheckRequested()) {
|
||||||
try {
|
try {
|
||||||
// During adding RequestGroup,
|
// During adding RequestGroup,
|
||||||
|
|
|
@ -44,6 +44,10 @@
|
||||||
#include "FtpConnection.h"
|
#include "FtpConnection.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -69,7 +73,7 @@ bool FtpDownloadCommand::prepareForNextSegment()
|
||||||
static_cast<uint64_t>(_fileEntry->gtoloff(_segments.front()->getPositionToWrite())) == _fileEntry->getLength()) {
|
static_cast<uint64_t>(_fileEntry->gtoloff(_segments.front()->getPositionToWrite())) == _fileEntry->getLength()) {
|
||||||
Command* command = new FtpFinishDownloadCommand
|
Command* command = new FtpFinishDownloadCommand
|
||||||
(cuid, req, _fileEntry, _requestGroup, _ftpConnection, e, ctrlSocket);
|
(cuid, req, _fileEntry, _requestGroup, _ftpConnection, e, ctrlSocket);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
|
|
||||||
if(_requestGroup->downloadFinished()) {
|
if(_requestGroup->downloadFinished()) {
|
||||||
// To run checksum checking, we had to call following function here.
|
// To run checksum checking, we had to call following function here.
|
||||||
|
|
|
@ -48,6 +48,10 @@
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -73,7 +77,7 @@ bool FtpFinishDownloadCommand::execute()
|
||||||
try {
|
try {
|
||||||
unsigned int status = _ftpConnection->receiveResponse();
|
unsigned int status = _ftpConnection->receiveResponse();
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(status != 226) {
|
if(status != 226) {
|
||||||
|
|
|
@ -54,6 +54,10 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "AuthConfigFactory.h"
|
#include "AuthConfigFactory.h"
|
||||||
#include "AuthConfig.h"
|
#include "AuthConfig.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,9 @@
|
||||||
#include "HttpResponse.h"
|
#include "HttpResponse.h"
|
||||||
#include "DlRetryEx.h"
|
#include "DlRetryEx.h"
|
||||||
#include "CookieStorage.h"
|
#include "CookieStorage.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -114,7 +117,7 @@ bool FtpNegotiationCommand::executeInternal() {
|
||||||
}
|
}
|
||||||
_requestGroup->getURISelector()->tuneDownloadCommand
|
_requestGroup->getURISelector()->tuneDownloadCommand
|
||||||
(_fileEntry->getRemainingUris(), command);
|
(_fileEntry->getRemainingUris(), command);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
return true;
|
return true;
|
||||||
} else if(sequence == SEQ_HEAD_OK || sequence == SEQ_DOWNLOAD_ALREADY_COMPLETED) {
|
} else if(sequence == SEQ_HEAD_OK || sequence == SEQ_DOWNLOAD_ALREADY_COMPLETED) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -128,7 +131,7 @@ bool FtpNegotiationCommand::executeInternal() {
|
||||||
} else if(sequence == SEQ_EXIT) {
|
} else if(sequence == SEQ_EXIT) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -358,7 +361,7 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength)
|
||||||
util::fixTaintedBasename(util::percentDecode(req->getFile()))));
|
util::fixTaintedBasename(util::percentDecode(req->getFile()))));
|
||||||
}
|
}
|
||||||
_requestGroup->preDownloadProcessing();
|
_requestGroup->preDownloadProcessing();
|
||||||
if(e->_requestGroupMan->isSameFileBeingDownloaded(_requestGroup)) {
|
if(e->getRequestGroupMan()->isSameFileBeingDownloaded(_requestGroup)) {
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION
|
throw DOWNLOAD_FAILURE_EXCEPTION
|
||||||
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
|
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
|
||||||
_requestGroup->getFirstFilePath().c_str()).str());
|
_requestGroup->getFirstFilePath().c_str()).str());
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
#include "PieceStorage.h"
|
#include "PieceStorage.h"
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -48,16 +51,17 @@ HaveEraseCommand::~HaveEraseCommand() {}
|
||||||
|
|
||||||
void HaveEraseCommand::preProcess()
|
void HaveEraseCommand::preProcess()
|
||||||
{
|
{
|
||||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
||||||
_exit = true;
|
_exit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HaveEraseCommand::process()
|
void HaveEraseCommand::process()
|
||||||
{
|
{
|
||||||
size_t numLoop = _e->_requestGroupMan->countRequestGroup();
|
size_t numLoop = _e->getRequestGroupMan()->countRequestGroup();
|
||||||
for(size_t i = 0; i < numLoop; ++i) {
|
for(size_t i = 0; i < numLoop; ++i) {
|
||||||
PieceStorageHandle ps = _e->_requestGroupMan->getRequestGroup(i)->getPieceStorage();
|
PieceStorageHandle ps =
|
||||||
|
_e->getRequestGroupMan()->getRequestGroup(i)->getPieceStorage();
|
||||||
if(!ps.isNull()) {
|
if(!ps.isNull()) {
|
||||||
ps->removeAdvertisedPiece(5);
|
ps->removeAdvertisedPiece(5);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,10 @@
|
||||||
#include "Range.h"
|
#include "Range.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "Decoder.h"
|
#include "Decoder.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -78,7 +82,7 @@ bool HttpDownloadCommand::prepareForNextSegment() {
|
||||||
if(resolveProxyMethod(req->getProtocol()) == V_GET) {
|
if(resolveProxyMethod(req->getProtocol()) == V_GET) {
|
||||||
command->setProxyRequest(createProxyRequest());
|
command->setProxyRequest(createProxyRequest());
|
||||||
}
|
}
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if(req->isPipeliningEnabled() ||
|
if(req->isPipeliningEnabled() ||
|
||||||
|
|
|
@ -49,7 +49,10 @@
|
||||||
#include "A2STR.h"
|
#include "A2STR.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
HttpInitiateConnectionCommand::HttpInitiateConnectionCommand
|
HttpInitiateConnectionCommand::HttpInitiateConnectionCommand
|
||||||
|
|
|
@ -45,6 +45,9 @@
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -60,7 +63,7 @@ HttpListenCommand::~HttpListenCommand()
|
||||||
|
|
||||||
bool HttpListenCommand::execute()
|
bool HttpListenCommand::execute()
|
||||||
{
|
{
|
||||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -77,14 +80,14 @@ bool HttpListenCommand::execute()
|
||||||
HttpServerCommand* c =
|
HttpServerCommand* c =
|
||||||
new HttpServerCommand(_e->newCUID(), _e, socket);
|
new HttpServerCommand(_e->newCUID(), _e, socket);
|
||||||
_e->setNoWait(true);
|
_e->setNoWait(true);
|
||||||
_e->commands.push_back(c);
|
_e->addCommand(c);
|
||||||
}
|
}
|
||||||
} catch(RecoverableException& e) {
|
} catch(RecoverableException& e) {
|
||||||
if(logger->debug()) {
|
if(logger->debug()) {
|
||||||
logger->debug(MSG_ACCEPT_FAILURE, e, util::itos(cuid).c_str());
|
logger->debug(MSG_ACCEPT_FAILURE, e, util::itos(cuid).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_e->commands.push_back(this);
|
_e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +103,7 @@ bool HttpListenCommand::bindPort(uint16_t port)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
if(_e->option->getAsBool(PREF_XML_RPC_LISTEN_ALL)) {
|
if(_e->getOption()->getAsBool(PREF_XML_RPC_LISTEN_ALL)) {
|
||||||
flags = AI_PASSIVE;
|
flags = AI_PASSIVE;
|
||||||
}
|
}
|
||||||
_serverSocket->bind(port, flags);
|
_serverSocket->bind(port, flags);
|
||||||
|
|
|
@ -53,6 +53,10 @@
|
||||||
#include "AuthConfigFactory.h"
|
#include "AuthConfigFactory.h"
|
||||||
#include "AuthConfig.h"
|
#include "AuthConfig.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -116,7 +120,7 @@ bool HttpRequestCommand::executeInternal() {
|
||||||
if(!socket->initiateSecureConnection(req->getHost())) {
|
if(!socket->initiateSecureConnection(req->getHost())) {
|
||||||
setReadCheckSocketIf(socket, socket->wantRead());
|
setReadCheckSocketIf(socket, socket->wantRead());
|
||||||
setWriteCheckSocketIf(socket, socket->wantWrite());
|
setWriteCheckSocketIf(socket, socket->wantWrite());
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,12 +168,12 @@ bool HttpRequestCommand::executeInternal() {
|
||||||
Command* command = new HttpResponseCommand(cuid, req, _fileEntry,
|
Command* command = new HttpResponseCommand(cuid, req, _fileEntry,
|
||||||
_requestGroup,
|
_requestGroup,
|
||||||
_httpConnection, e, socket);
|
_httpConnection, e, socket);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
setReadCheckSocketIf(socket, socket->wantRead());
|
setReadCheckSocketIf(socket, socket->wantRead());
|
||||||
setWriteCheckSocketIf(socket, socket->wantWrite());
|
setWriteCheckSocketIf(socket, socket->wantWrite());
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,9 @@
|
||||||
#include "AuthConfig.h"
|
#include "AuthConfig.h"
|
||||||
#include "a2functional.h"
|
#include "a2functional.h"
|
||||||
#include "URISelector.h"
|
#include "URISelector.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -98,7 +101,7 @@ bool HttpResponseCommand::executeInternal()
|
||||||
// For socket->wantRead() == true, setReadCheckSocket(socket) is already
|
// For socket->wantRead() == true, setReadCheckSocket(socket) is already
|
||||||
// done in the constructor.
|
// done in the constructor.
|
||||||
setWriteCheckSocketIf(socket, socket->wantWrite());
|
setWriteCheckSocketIf(socket, socket->wantWrite());
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// check HTTP status number
|
// check HTTP status number
|
||||||
|
@ -137,7 +140,7 @@ bool HttpResponseCommand::executeInternal()
|
||||||
}
|
}
|
||||||
_fileEntry->setContentType(httpResponse->getContentType());
|
_fileEntry->setContentType(httpResponse->getContentType());
|
||||||
_requestGroup->preDownloadProcessing();
|
_requestGroup->preDownloadProcessing();
|
||||||
if(e->_requestGroupMan->isSameFileBeingDownloaded(_requestGroup)) {
|
if(e->getRequestGroupMan()->isSameFileBeingDownloaded(_requestGroup)) {
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION
|
throw DOWNLOAD_FAILURE_EXCEPTION
|
||||||
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
|
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
|
||||||
_requestGroup->getFirstFilePath().c_str()).str());
|
_requestGroup->getFirstFilePath().c_str()).str());
|
||||||
|
@ -173,12 +176,12 @@ bool HttpResponseCommand::executeInternal()
|
||||||
// Also we can't resume in this case too. So truncate the file
|
// Also we can't resume in this case too. So truncate the file
|
||||||
// anyway.
|
// anyway.
|
||||||
_requestGroup->getPieceStorage()->getDiskAdaptor()->truncate(0);
|
_requestGroup->getPieceStorage()->getDiskAdaptor()->truncate(0);
|
||||||
e->commands.push_back
|
e->addCommand
|
||||||
(createHttpDownloadCommand(httpResponse,
|
(createHttpDownloadCommand(httpResponse,
|
||||||
getTransferEncodingDecoder(httpResponse),
|
getTransferEncodingDecoder(httpResponse),
|
||||||
getContentEncodingDecoder(httpResponse)));
|
getContentEncodingDecoder(httpResponse)));
|
||||||
} else {
|
} else {
|
||||||
e->commands.push_back(createHttpDownloadCommand(httpResponse,
|
e->addCommand(createHttpDownloadCommand(httpResponse,
|
||||||
getTransferEncodingDecoder(httpResponse)));
|
getTransferEncodingDecoder(httpResponse)));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -347,7 +350,7 @@ bool HttpResponseCommand::handleOtherEncoding
|
||||||
// AbstractCommand::execute()
|
// AbstractCommand::execute()
|
||||||
_requestGroup->getSegmentMan()->getSegment(cuid, 0);
|
_requestGroup->getSegmentMan()->getSegment(cuid, 0);
|
||||||
|
|
||||||
e->commands.push_back
|
e->addCommand
|
||||||
(createHttpDownloadCommand(httpResponse,
|
(createHttpDownloadCommand(httpResponse,
|
||||||
getTransferEncodingDecoder(httpResponse),
|
getTransferEncodingDecoder(httpResponse),
|
||||||
getContentEncodingDecoder(httpResponse)));
|
getContentEncodingDecoder(httpResponse)));
|
||||||
|
@ -376,7 +379,7 @@ bool HttpResponseCommand::skipResponseBody
|
||||||
e->setNoWait(true);
|
e->setNoWait(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,9 @@
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -76,7 +79,7 @@ HttpServerBodyCommand::~HttpServerBodyCommand()
|
||||||
|
|
||||||
bool HttpServerBodyCommand::execute()
|
bool HttpServerBodyCommand::execute()
|
||||||
{
|
{
|
||||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -97,14 +100,14 @@ bool HttpServerBodyCommand::execute()
|
||||||
_httpServer->feedResponse(responseData, "text/xml");
|
_httpServer->feedResponse(responseData, "text/xml");
|
||||||
Command* command =
|
Command* command =
|
||||||
new HttpServerResponseCommand(cuid, _httpServer, _e, _socket);
|
new HttpServerResponseCommand(cuid, _httpServer, _e, _socket);
|
||||||
_e->commands.push_back(command);
|
_e->addCommand(command);
|
||||||
_e->setNoWait(true);
|
_e->setNoWait(true);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_e->commands.push_back(this);
|
_e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -112,7 +115,7 @@ bool HttpServerBodyCommand::execute()
|
||||||
logger->info("HTTP request body timeout.");
|
logger->info("HTTP request body timeout.");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
_e->commands.push_back(this);
|
_e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,9 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -60,8 +63,8 @@ HttpServerCommand::HttpServerCommand(cuid_t cuid, DownloadEngine* e,
|
||||||
{
|
{
|
||||||
setStatus(Command::STATUS_ONESHOT_REALTIME);
|
setStatus(Command::STATUS_ONESHOT_REALTIME);
|
||||||
_e->addSocketForReadCheck(_socket, this);
|
_e->addSocketForReadCheck(_socket, this);
|
||||||
_httpServer->setUsernamePassword(_e->option->get(PREF_XML_RPC_USER),
|
_httpServer->setUsernamePassword(_e->getOption()->get(PREF_XML_RPC_USER),
|
||||||
_e->option->get(PREF_XML_RPC_PASSWD));
|
_e->getOption()->get(PREF_XML_RPC_PASSWD));
|
||||||
#ifdef HAVE_LIBZ
|
#ifdef HAVE_LIBZ
|
||||||
_httpServer->enableGZip();
|
_httpServer->enableGZip();
|
||||||
#else // !HAVE_LIBZ
|
#else // !HAVE_LIBZ
|
||||||
|
@ -88,7 +91,7 @@ HttpServerCommand::~HttpServerCommand()
|
||||||
|
|
||||||
bool HttpServerCommand::execute()
|
bool HttpServerCommand::execute()
|
||||||
{
|
{
|
||||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -99,7 +102,7 @@ bool HttpServerCommand::execute()
|
||||||
header = _httpServer->receiveRequest();
|
header = _httpServer->receiveRequest();
|
||||||
|
|
||||||
if(header.isNull()) {
|
if(header.isNull()) {
|
||||||
_e->commands.push_back(this);
|
_e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!_httpServer->authenticate()) {
|
if(!_httpServer->authenticate()) {
|
||||||
|
@ -109,12 +112,12 @@ bool HttpServerCommand::execute()
|
||||||
"","text/html");
|
"","text/html");
|
||||||
Command* command =
|
Command* command =
|
||||||
new HttpServerResponseCommand(cuid, _httpServer, _e, _socket);
|
new HttpServerResponseCommand(cuid, _httpServer, _e, _socket);
|
||||||
_e->commands.push_back(command);
|
_e->addCommand(command);
|
||||||
_e->setNoWait(true);
|
_e->setNoWait(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(static_cast<uint64_t>
|
if(static_cast<uint64_t>
|
||||||
(_e->option->getAsInt(PREF_XML_RPC_MAX_REQUEST_SIZE)) <
|
(_e->getOption()->getAsInt(PREF_XML_RPC_MAX_REQUEST_SIZE)) <
|
||||||
_httpServer->getContentLength()) {
|
_httpServer->getContentLength()) {
|
||||||
logger->info("Request too long. ContentLength=%s."
|
logger->info("Request too long. ContentLength=%s."
|
||||||
" See --xml-rpc-max-request-size option to loose"
|
" See --xml-rpc-max-request-size option to loose"
|
||||||
|
@ -124,7 +127,7 @@ bool HttpServerCommand::execute()
|
||||||
}
|
}
|
||||||
Command* command = new HttpServerBodyCommand(cuid, _httpServer, _e,
|
Command* command = new HttpServerBodyCommand(cuid, _httpServer, _e,
|
||||||
_socket);
|
_socket);
|
||||||
_e->commands.push_back(command);
|
_e->addCommand(command);
|
||||||
_e->setNoWait(true);
|
_e->setNoWait(true);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -132,7 +135,7 @@ bool HttpServerCommand::execute()
|
||||||
logger->info("HTTP request timeout.");
|
logger->info("HTTP request timeout.");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
_e->commands.push_back(this);
|
_e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,9 @@
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -67,7 +70,7 @@ HttpServerResponseCommand::~HttpServerResponseCommand()
|
||||||
|
|
||||||
bool HttpServerResponseCommand::execute()
|
bool HttpServerResponseCommand::execute()
|
||||||
{
|
{
|
||||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -88,8 +91,7 @@ bool HttpServerResponseCommand::execute()
|
||||||
if(logger->info()) {
|
if(logger->info()) {
|
||||||
logger->info("CUID#%s - Persist connection.", util::itos(cuid).c_str());
|
logger->info("CUID#%s - Persist connection.", util::itos(cuid).c_str());
|
||||||
}
|
}
|
||||||
_e->commands.push_back
|
_e->addCommand(new HttpServerCommand(cuid, _httpServer, _e, _socket));
|
||||||
(new HttpServerCommand(cuid, _httpServer, _e, _socket));
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -100,7 +102,7 @@ bool HttpServerResponseCommand::execute()
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
_e->commands.push_back(this);
|
_e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,10 @@
|
||||||
#include "AuthConfigFactory.h"
|
#include "AuthConfigFactory.h"
|
||||||
#include "AuthConfig.h"
|
#include "AuthConfig.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -137,7 +141,7 @@ bool HttpSkipResponseCommand::executeInternal()
|
||||||
return processResponse();
|
return processResponse();
|
||||||
} else {
|
} else {
|
||||||
setWriteCheckSocketIf(socket, socket->wantWrite());
|
setWriteCheckSocketIf(socket, socket->wantWrite());
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,10 @@
|
||||||
#include "a2functional.h"
|
#include "a2functional.h"
|
||||||
#include "InitiateConnectionCommandFactory.h"
|
#include "InitiateConnectionCommandFactory.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -82,13 +86,13 @@ bool InitiateConnectionCommand::executeInternal() {
|
||||||
std::vector<std::string> addrs;
|
std::vector<std::string> addrs;
|
||||||
std::string ipaddr = resolveHostname(addrs, hostname, port);
|
std::string ipaddr = resolveHostname(addrs, hostname, port);
|
||||||
if(ipaddr.empty()) {
|
if(ipaddr.empty()) {
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Command* command = createNextCommand(hostname, ipaddr, port,
|
Command* command = createNextCommand(hostname, ipaddr, port,
|
||||||
addrs, proxyRequest);
|
addrs, proxyRequest);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
return true;
|
return true;
|
||||||
} catch(RecoverableException& ex) {
|
} catch(RecoverableException& ex) {
|
||||||
// Catch exception and retry another address.
|
// Catch exception and retry another address.
|
||||||
|
@ -106,7 +110,7 @@ bool InitiateConnectionCommand::executeInternal() {
|
||||||
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||||
(cuid, req, _fileEntry, _requestGroup, e);
|
(cuid, req, _fileEntry, _requestGroup, e);
|
||||||
e->setNoWait(true);
|
e->setNoWait(true);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
e->removeCachedIPAddress(hostname, port);
|
e->removeCachedIPAddress(hostname, port);
|
||||||
|
|
|
@ -44,6 +44,10 @@
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "SocketCore.h"
|
#include "SocketCore.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,10 @@
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "bittorrent_helper.h"
|
#include "bittorrent_helper.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -157,13 +161,13 @@ bool InitiatorMSEHandshakeCommand::executeInternal() {
|
||||||
socket,
|
socket,
|
||||||
PeerInteractionCommand::INITIATOR_SEND_HANDSHAKE,
|
PeerInteractionCommand::INITIATOR_SEND_HANDSHAKE,
|
||||||
peerConnection);
|
peerConnection);
|
||||||
e->commands.push_back(c);
|
e->addCommand(c);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +187,7 @@ bool InitiatorMSEHandshakeCommand::prepareForNextPeer(time_t wait)
|
||||||
e, _btRuntime);
|
e, _btRuntime);
|
||||||
command->setPeerStorage(_peerStorage);
|
command->setPeerStorage(_peerStorage);
|
||||||
command->setPieceStorage(_pieceStorage);
|
command->setPieceStorage(_pieceStorage);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -197,7 +201,7 @@ bool InitiatorMSEHandshakeCommand::prepareForNextPeer(time_t wait)
|
||||||
_btRuntime, false);
|
_btRuntime, false);
|
||||||
command->setPeerStorage(_peerStorage);
|
command->setPeerStorage(_peerStorage);
|
||||||
command->setPieceStorage(_pieceStorage);
|
command->setPieceStorage(_pieceStorage);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,11 @@
|
||||||
#include "RecoverableException.h"
|
#include "RecoverableException.h"
|
||||||
#include "SocketCore.h"
|
#include "SocketCore.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -81,7 +86,7 @@ bool LpdDispatchMessageCommand::execute()
|
||||||
_tryCount = 0;
|
_tryCount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_e->commands.push_back(this);
|
_e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,9 @@
|
||||||
#include "BtAnnounce.h"
|
#include "BtAnnounce.h"
|
||||||
#include "LpdMessage.h"
|
#include "LpdMessage.h"
|
||||||
#include "bittorrent_helper.h"
|
#include "bittorrent_helper.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -75,7 +78,7 @@ LpdReceiveMessageCommand::~LpdReceiveMessageCommand()
|
||||||
|
|
||||||
bool LpdReceiveMessageCommand::execute()
|
bool LpdReceiveMessageCommand::execute()
|
||||||
{
|
{
|
||||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for(size_t i = 0; i < 20; ++i) {
|
for(size_t i = 0; i < 20; ++i) {
|
||||||
|
@ -127,7 +130,7 @@ bool LpdReceiveMessageCommand::execute()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_e->commands.push_back(this);
|
_e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,8 @@
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "SessionSerializer.h"
|
#include "SessionSerializer.h"
|
||||||
#include "ServerStatMan.h"
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
#ifdef ENABLE_SSL
|
#ifdef ENABLE_SSL
|
||||||
# include "SocketCore.h"
|
# include "SocketCore.h"
|
||||||
# include "TLSContext.h"
|
# include "TLSContext.h"
|
||||||
|
@ -176,8 +178,8 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute()
|
||||||
|
|
||||||
std::string serverStatIf = _option->get(PREF_SERVER_STAT_IF);
|
std::string serverStatIf = _option->get(PREF_SERVER_STAT_IF);
|
||||||
if(!serverStatIf.empty()) {
|
if(!serverStatIf.empty()) {
|
||||||
e->_requestGroupMan->loadServerStat(serverStatIf);
|
e->getRequestGroupMan()->loadServerStat(serverStatIf);
|
||||||
e->_requestGroupMan->removeStaleServerStat
|
e->getRequestGroupMan()->removeStaleServerStat
|
||||||
(_option->getAsInt(PREF_SERVER_STAT_TIMEOUT));
|
(_option->getAsInt(PREF_SERVER_STAT_TIMEOUT));
|
||||||
}
|
}
|
||||||
e->setStatCalc(_statCalc);
|
e->setStatCalc(_statCalc);
|
||||||
|
@ -195,12 +197,13 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute()
|
||||||
|
|
||||||
std::string serverStatOf = _option->get(PREF_SERVER_STAT_OF);
|
std::string serverStatOf = _option->get(PREF_SERVER_STAT_OF);
|
||||||
if(!serverStatOf.empty()) {
|
if(!serverStatOf.empty()) {
|
||||||
e->_requestGroupMan->saveServerStat(serverStatOf);
|
e->getRequestGroupMan()->saveServerStat(serverStatOf);
|
||||||
}
|
}
|
||||||
e->_requestGroupMan->showDownloadResults(_summaryOut);
|
e->getRequestGroupMan()->showDownloadResults(_summaryOut);
|
||||||
_summaryOut << std::flush;
|
_summaryOut << std::flush;
|
||||||
|
|
||||||
RequestGroupMan::DownloadStat s = e->_requestGroupMan->getDownloadStat();
|
RequestGroupMan::DownloadStat s =
|
||||||
|
e->getRequestGroupMan()->getDownloadStat();
|
||||||
if(!s.allCompleted()) {
|
if(!s.allCompleted()) {
|
||||||
printMessageForContinue();
|
printMessageForContinue();
|
||||||
if(s.getLastErrorResult() == downloadresultcode::FINISHED &&
|
if(s.getLastErrorResult() == downloadresultcode::FINISHED &&
|
||||||
|
@ -210,7 +213,7 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute()
|
||||||
returnValue = s.getLastErrorResult();
|
returnValue = s.getLastErrorResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SessionSerializer sessionSerializer(e->_requestGroupMan);
|
SessionSerializer sessionSerializer(e->getRequestGroupMan());
|
||||||
// TODO Add option: --save-session-status=error,inprogress,waiting
|
// TODO Add option: --save-session-status=error,inprogress,waiting
|
||||||
if(!_option->blank(PREF_SAVE_SESSION)) {
|
if(!_option->blank(PREF_SAVE_SESSION)) {
|
||||||
const std::string& filename = _option->get(PREF_SAVE_SESSION);
|
const std::string& filename = _option->get(PREF_SAVE_SESSION);
|
||||||
|
|
|
@ -45,6 +45,11 @@
|
||||||
#include "StringFormat.h"
|
#include "StringFormat.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -65,7 +70,7 @@ PeerAbstractCommand::PeerAbstractCommand(cuid_t cuid,
|
||||||
setReadCheckSocket(socket);
|
setReadCheckSocket(socket);
|
||||||
}
|
}
|
||||||
// TODO referring global option
|
// TODO referring global option
|
||||||
timeout = e->option->getAsInt(PREF_BT_TIMEOUT);
|
timeout = e->getOption()->getAsInt(PREF_BT_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerAbstractCommand::~PeerAbstractCommand()
|
PeerAbstractCommand::~PeerAbstractCommand()
|
||||||
|
|
|
@ -36,6 +36,11 @@
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "BtRuntime.h"
|
#include "BtRuntime.h"
|
||||||
#include "PeerStorage.h"
|
#include "PeerStorage.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -53,7 +58,7 @@ bool PeerChokeCommand::execute() {
|
||||||
if(_peerStorage->chokeRoundIntervalElapsed()) {
|
if(_peerStorage->chokeRoundIntervalElapsed()) {
|
||||||
_peerStorage->executeChoke();
|
_peerStorage->executeChoke();
|
||||||
}
|
}
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,10 @@
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -89,13 +93,13 @@ bool PeerInitiateConnectionCommand::executeInternal() {
|
||||||
_btRuntime, socket);
|
_btRuntime, socket);
|
||||||
c->setPeerStorage(_peerStorage);
|
c->setPeerStorage(_peerStorage);
|
||||||
c->setPieceStorage(_pieceStorage);
|
c->setPieceStorage(_pieceStorage);
|
||||||
e->commands.push_back(c);
|
e->addCommand(c);
|
||||||
} else {
|
} else {
|
||||||
PeerInteractionCommand* command =
|
PeerInteractionCommand* command =
|
||||||
new PeerInteractionCommand
|
new PeerInteractionCommand
|
||||||
(cuid, _requestGroup, peer, e, _btRuntime, _pieceStorage, _peerStorage,
|
(cuid, _requestGroup, peer, e, _btRuntime, _pieceStorage, _peerStorage,
|
||||||
socket, PeerInteractionCommand::INITIATOR_SEND_HANDSHAKE);
|
socket, PeerInteractionCommand::INITIATOR_SEND_HANDSHAKE);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +114,7 @@ bool PeerInitiateConnectionCommand::prepareForNextPeer(time_t wait) {
|
||||||
_btRuntime);
|
_btRuntime);
|
||||||
command->setPeerStorage(_peerStorage);
|
command->setPeerStorage(_peerStorage);
|
||||||
command->setPieceStorage(_pieceStorage);
|
command->setPieceStorage(_pieceStorage);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,9 @@
|
||||||
#include "bittorrent_helper.h"
|
#include "bittorrent_helper.h"
|
||||||
#include "UTMetadataRequestFactory.h"
|
#include "UTMetadataRequestFactory.h"
|
||||||
#include "UTMetadataRequestTracker.h"
|
#include "UTMetadataRequestTracker.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -155,7 +158,7 @@ PeerInteractionCommand::PeerInteractionCommand
|
||||||
dispatcher->setPeerStorage(peerStorage);
|
dispatcher->setPeerStorage(peerStorage);
|
||||||
dispatcher->setRequestTimeout(getOption()->getAsInt(PREF_BT_REQUEST_TIMEOUT));
|
dispatcher->setRequestTimeout(getOption()->getAsInt(PREF_BT_REQUEST_TIMEOUT));
|
||||||
dispatcher->setBtMessageFactory(factory);
|
dispatcher->setBtMessageFactory(factory);
|
||||||
dispatcher->setRequestGroupMan(e->_requestGroupMan);
|
dispatcher->setRequestGroupMan(e->getRequestGroupMan());
|
||||||
|
|
||||||
DefaultBtMessageReceiverHandle receiver(new DefaultBtMessageReceiver());
|
DefaultBtMessageReceiverHandle receiver(new DefaultBtMessageReceiver());
|
||||||
receiver->setCuid(cuid);
|
receiver->setCuid(cuid);
|
||||||
|
@ -187,7 +190,7 @@ PeerInteractionCommand::PeerInteractionCommand
|
||||||
btInteractive->setExtensionMessageRegistry(exMsgRegistry);
|
btInteractive->setExtensionMessageRegistry(exMsgRegistry);
|
||||||
btInteractive->setKeepAliveInterval
|
btInteractive->setKeepAliveInterval
|
||||||
(getOption()->getAsInt(PREF_BT_KEEP_ALIVE_INTERVAL));
|
(getOption()->getAsInt(PREF_BT_KEEP_ALIVE_INTERVAL));
|
||||||
btInteractive->setRequestGroupMan(e->_requestGroupMan);
|
btInteractive->setRequestGroupMan(e->getRequestGroupMan());
|
||||||
btInteractive->setBtMessageFactory(factory);
|
btInteractive->setBtMessageFactory(factory);
|
||||||
if((metadataGetMode || torrentAttrs[bittorrent::PRIVATE].i() == 0) &&
|
if((metadataGetMode || torrentAttrs[bittorrent::PRIVATE].i() == 0) &&
|
||||||
!peer->isLocalPeer()) {
|
!peer->isLocalPeer()) {
|
||||||
|
@ -301,7 +304,7 @@ bool PeerInteractionCommand::executeInternal() {
|
||||||
setWriteCheckSocket(socket);
|
setWriteCheckSocket(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e->_requestGroupMan->doesOverallDownloadSpeedExceed() ||
|
if(e->getRequestGroupMan()->doesOverallDownloadSpeedExceed() ||
|
||||||
_requestGroup->doesDownloadSpeedExceed()) {
|
_requestGroup->doesDownloadSpeedExceed()) {
|
||||||
disableReadCheckSocket();
|
disableReadCheckSocket();
|
||||||
setNoCheck(true);
|
setNoCheck(true);
|
||||||
|
@ -316,7 +319,7 @@ bool PeerInteractionCommand::executeInternal() {
|
||||||
if(btInteractive->countPendingMessage() > 0) {
|
if(btInteractive->countPendingMessage() > 0) {
|
||||||
setNoCheck(true);
|
setNoCheck(true);
|
||||||
}
|
}
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +333,7 @@ bool PeerInteractionCommand::prepareForNextPeer(time_t wait) {
|
||||||
(peer->usedBy(), _requestGroup, peer, e, _btRuntime);
|
(peer->usedBy(), _requestGroup, peer, e, _btRuntime);
|
||||||
command->setPeerStorage(_peerStorage);
|
command->setPeerStorage(_peerStorage);
|
||||||
command->setPieceStorage(_pieceStorage);
|
command->setPieceStorage(_pieceStorage);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,9 @@
|
||||||
#include "SimpleRandomizer.h"
|
#include "SimpleRandomizer.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -108,7 +111,7 @@ uint16_t PeerListenCommand::getPort() const
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PeerListenCommand::execute() {
|
bool PeerListenCommand::execute() {
|
||||||
if(e->isHaltRequested() || e->_requestGroupMan->downloadFinished()) {
|
if(e->isHaltRequested() || e->getRequestGroupMan()->downloadFinished()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for(int i = 0; i < 3 && socket->isReadable(0); ++i) {
|
for(int i = 0; i < 3 && socket->isReadable(0); ++i) {
|
||||||
|
@ -124,7 +127,7 @@ bool PeerListenCommand::execute() {
|
||||||
cuid_t cuid = e->newCUID();
|
cuid_t cuid = e->newCUID();
|
||||||
Command* command =
|
Command* command =
|
||||||
new ReceiverMSEHandshakeCommand(cuid, peer, e, peerSocket);
|
new ReceiverMSEHandshakeCommand(cuid, peer, e, peerSocket);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
if(logger->debug()) {
|
if(logger->debug()) {
|
||||||
logger->debug("Accepted the connection from %s:%u.",
|
logger->debug("Accepted the connection from %s:%u.",
|
||||||
peer->ipaddr.c_str(),
|
peer->ipaddr.c_str(),
|
||||||
|
@ -136,7 +139,7 @@ bool PeerListenCommand::execute() {
|
||||||
logger->debug(MSG_ACCEPT_FAILURE, ex, util::itos(cuid).c_str());
|
logger->debug(MSG_ACCEPT_FAILURE, ex, util::itos(cuid).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,9 @@
|
||||||
#include "RequestGroupMan.h"
|
#include "RequestGroupMan.h"
|
||||||
#include "StringFormat.h"
|
#include "StringFormat.h"
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -78,7 +81,7 @@ PeerReceiveHandshakeCommand::~PeerReceiveHandshakeCommand() {}
|
||||||
|
|
||||||
bool PeerReceiveHandshakeCommand::exitBeforeExecute()
|
bool PeerReceiveHandshakeCommand::exitBeforeExecute()
|
||||||
{
|
{
|
||||||
return e->isHaltRequested() || e->_requestGroupMan->downloadFinished();
|
return e->isHaltRequested() || e->getRequestGroupMan()->downloadFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PeerReceiveHandshakeCommand::executeInternal()
|
bool PeerReceiveHandshakeCommand::executeInternal()
|
||||||
|
@ -141,7 +144,7 @@ bool PeerReceiveHandshakeCommand::executeInternal()
|
||||||
socket,
|
socket,
|
||||||
PeerInteractionCommand::RECEIVER_WAIT_HANDSHAKE,
|
PeerInteractionCommand::RECEIVER_WAIT_HANDSHAKE,
|
||||||
_peerConnection);
|
_peerConnection);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
if(logger->debug()) {
|
if(logger->debug()) {
|
||||||
logger->debug(MSG_INCOMING_PEER_CONNECTION,
|
logger->debug(MSG_INCOMING_PEER_CONNECTION,
|
||||||
util::itos(cuid).c_str(),
|
util::itos(cuid).c_str(),
|
||||||
|
@ -151,7 +154,7 @@ bool PeerReceiveHandshakeCommand::executeInternal()
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,10 @@
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,9 @@
|
||||||
#include "BtAnnounce.h"
|
#include "BtAnnounce.h"
|
||||||
#include "BtRuntime.h"
|
#include "BtRuntime.h"
|
||||||
#include "BtProgressInfoFile.h"
|
#include "BtProgressInfoFile.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -66,9 +69,9 @@ ReceiverMSEHandshakeCommand::ReceiverMSEHandshakeCommand
|
||||||
|
|
||||||
PeerAbstractCommand(cuid, peer, e, s),
|
PeerAbstractCommand(cuid, peer, e, s),
|
||||||
_sequence(RECEIVER_IDENTIFY_HANDSHAKE),
|
_sequence(RECEIVER_IDENTIFY_HANDSHAKE),
|
||||||
_mseHandshake(new MSEHandshake(cuid, s, e->option))
|
_mseHandshake(new MSEHandshake(cuid, s, e->getOption()))
|
||||||
{
|
{
|
||||||
setTimeout(e->option->getAsInt(PREF_PEER_CONNECTION_TIMEOUT));
|
setTimeout(e->getOption()->getAsInt(PREF_PEER_CONNECTION_TIMEOUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
ReceiverMSEHandshakeCommand::~ReceiverMSEHandshakeCommand()
|
ReceiverMSEHandshakeCommand::~ReceiverMSEHandshakeCommand()
|
||||||
|
@ -78,7 +81,7 @@ ReceiverMSEHandshakeCommand::~ReceiverMSEHandshakeCommand()
|
||||||
|
|
||||||
bool ReceiverMSEHandshakeCommand::exitBeforeExecute()
|
bool ReceiverMSEHandshakeCommand::exitBeforeExecute()
|
||||||
{
|
{
|
||||||
return e->isHaltRequested() || e->_requestGroupMan->downloadFinished();
|
return e->isHaltRequested() || e->getRequestGroupMan()->downloadFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReceiverMSEHandshakeCommand::executeInternal()
|
bool ReceiverMSEHandshakeCommand::executeInternal()
|
||||||
|
@ -94,7 +97,7 @@ bool ReceiverMSEHandshakeCommand::executeInternal()
|
||||||
_sequence = RECEIVER_WAIT_KEY;
|
_sequence = RECEIVER_WAIT_KEY;
|
||||||
break;
|
break;
|
||||||
case MSEHandshake::HANDSHAKE_LEGACY: {
|
case MSEHandshake::HANDSHAKE_LEGACY: {
|
||||||
if(e->option->getAsBool(PREF_BT_REQUIRE_CRYPTO)) {
|
if(e->getOption()->getAsBool(PREF_BT_REQUIRE_CRYPTO)) {
|
||||||
throw DL_ABORT_EX("The legacy BitTorrent handshake is not acceptable by the preference.");
|
throw DL_ABORT_EX("The legacy BitTorrent handshake is not acceptable by the preference.");
|
||||||
}
|
}
|
||||||
SharedHandle<PeerConnection> peerConnection
|
SharedHandle<PeerConnection> peerConnection
|
||||||
|
@ -103,7 +106,7 @@ bool ReceiverMSEHandshakeCommand::executeInternal()
|
||||||
_mseHandshake->getBufferLength());
|
_mseHandshake->getBufferLength());
|
||||||
Command* c = new PeerReceiveHandshakeCommand(cuid, peer, e, socket,
|
Command* c = new PeerReceiveHandshakeCommand(cuid, peer, e, socket,
|
||||||
peerConnection);
|
peerConnection);
|
||||||
e->commands.push_back(c);
|
e->addCommand(c);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -175,7 +178,7 @@ bool ReceiverMSEHandshakeCommand::executeInternal()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +199,7 @@ void ReceiverMSEHandshakeCommand::createCommand()
|
||||||
// match, then drop connection.
|
// match, then drop connection.
|
||||||
Command* c =
|
Command* c =
|
||||||
new PeerReceiveHandshakeCommand(cuid, peer, e, socket, peerConnection);
|
new PeerReceiveHandshakeCommand(cuid, peer, e, socket, peerConnection);
|
||||||
e->commands.push_back(c);
|
e->addCommand(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -76,6 +76,7 @@
|
||||||
#include "a2functional.h"
|
#include "a2functional.h"
|
||||||
#include "SocketCore.h"
|
#include "SocketCore.h"
|
||||||
#include "SimpleRandomizer.h"
|
#include "SimpleRandomizer.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
# include "CheckIntegrityCommand.h"
|
# include "CheckIntegrityCommand.h"
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
@ -221,7 +222,7 @@ void RequestGroup::createInitialCommand
|
||||||
// Use UnknownLengthPieceStorage.
|
// Use UnknownLengthPieceStorage.
|
||||||
initPieceStorage();
|
initPieceStorage();
|
||||||
} else {
|
} else {
|
||||||
if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
|
if(e->getRequestGroupMan()->isSameFileBeingDownloaded(this)) {
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION
|
throw DOWNLOAD_FAILURE_EXCEPTION
|
||||||
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
|
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
|
||||||
_downloadContext->getBasePath().c_str()).str());
|
_downloadContext->getBasePath().c_str()).str());
|
||||||
|
@ -356,7 +357,7 @@ void RequestGroup::createInitialCommand
|
||||||
command->setTaskFactory(DHTRegistry::_taskFactory);
|
command->setTaskFactory(DHTRegistry::_taskFactory);
|
||||||
command->setRoutingTable(DHTRegistry::_routingTable);
|
command->setRoutingTable(DHTRegistry::_routingTable);
|
||||||
command->setLocalNode(DHTRegistry::_localNode);
|
command->setLocalNode(DHTRegistry::_localNode);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SharedHandle<CheckIntegrityEntry> entry(new BtCheckIntegrityEntry(this));
|
SharedHandle<CheckIntegrityEntry> entry(new BtCheckIntegrityEntry(this));
|
||||||
|
@ -379,7 +380,7 @@ void RequestGroup::createInitialCommand
|
||||||
_downloadContext->getTotalLength() == 0) {
|
_downloadContext->getTotalLength() == 0) {
|
||||||
createNextCommand(commands, e, 1);
|
createNextCommand(commands, e, 1);
|
||||||
}else {
|
}else {
|
||||||
if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
|
if(e->getRequestGroupMan()->isSameFileBeingDownloaded(this)) {
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION
|
throw DOWNLOAD_FAILURE_EXCEPTION
|
||||||
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
|
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
|
||||||
_downloadContext->getBasePath().c_str()).str());
|
_downloadContext->getBasePath().c_str()).str());
|
||||||
|
@ -408,7 +409,7 @@ void RequestGroup::createInitialCommand
|
||||||
} else {
|
} else {
|
||||||
// In this context, multiple FileEntry objects are in
|
// In this context, multiple FileEntry objects are in
|
||||||
// DownloadContext.
|
// DownloadContext.
|
||||||
if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
|
if(e->getRequestGroupMan()->isSameFileBeingDownloaded(this)) {
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION
|
throw DOWNLOAD_FAILURE_EXCEPTION
|
||||||
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
|
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
|
||||||
_downloadContext->getBasePath().c_str()).str());
|
_downloadContext->getBasePath().c_str()).str());
|
||||||
|
@ -467,7 +468,7 @@ void RequestGroup::processCheckIntegrityEntry
|
||||||
// enableSaveControlFile() will be called after hash checking is
|
// enableSaveControlFile() will be called after hash checking is
|
||||||
// done. See CheckIntegrityCommand.
|
// done. See CheckIntegrityCommand.
|
||||||
disableSaveControlFile();
|
disableSaveControlFile();
|
||||||
e->_checkIntegrityMan->pushEntry(entry);
|
e->getCheckIntegrityMan()->pushEntry(entry);
|
||||||
} else
|
} else
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,6 +67,8 @@
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "StringFormat.h"
|
#include "StringFormat.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -379,7 +381,7 @@ public:
|
||||||
("Adding %lu RequestGroups as a result of PostDownloadHandler.",
|
("Adding %lu RequestGroups as a result of PostDownloadHandler.",
|
||||||
static_cast<unsigned long>(nextGroups.size()));
|
static_cast<unsigned long>(nextGroups.size()));
|
||||||
}
|
}
|
||||||
_e->_requestGroupMan->insertReservedGroup(0, nextGroups);
|
_e->getRequestGroupMan()->insertReservedGroup(0, nextGroups);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
group->saveControlFile();
|
group->saveControlFile();
|
||||||
|
@ -395,11 +397,11 @@ public:
|
||||||
group->releaseRuntimeResource(_e);
|
group->releaseRuntimeResource(_e);
|
||||||
if(group->isPauseRequested()) {
|
if(group->isPauseRequested()) {
|
||||||
group->setForceHaltRequested(false);
|
group->setForceHaltRequested(false);
|
||||||
executeHookByOptName(group, _e->option, PREF_ON_DOWNLOAD_PAUSE);
|
executeHookByOptName(group, _e->getOption(), PREF_ON_DOWNLOAD_PAUSE);
|
||||||
// TODO Should we have to prepend spend uris to remaining uris
|
// TODO Should we have to prepend spend uris to remaining uris
|
||||||
// in case PREF_REUSE_URI is disabed?
|
// in case PREF_REUSE_URI is disabed?
|
||||||
} else {
|
} else {
|
||||||
executeStopHook(_downloadResults.back(), _e->option);
|
executeStopHook(_downloadResults.back(), _e->getOption());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -541,7 +543,7 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
|
||||||
++count;
|
++count;
|
||||||
e->addCommand(commands);
|
e->addCommand(commands);
|
||||||
commands.clear();
|
commands.clear();
|
||||||
executeHookByOptName(groupToAdd, e->option, PREF_ON_DOWNLOAD_START);
|
executeHookByOptName(groupToAdd, e->getOption(), PREF_ON_DOWNLOAD_START);
|
||||||
} catch(RecoverableException& ex) {
|
} catch(RecoverableException& ex) {
|
||||||
_logger->error(EX_EXCEPTION_CAUGHT, ex);
|
_logger->error(EX_EXCEPTION_CAUGHT, ex);
|
||||||
if(_logger->debug()) {
|
if(_logger->debug()) {
|
||||||
|
|
|
@ -41,6 +41,10 @@
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -83,7 +87,7 @@ bool SeedCheckCommand::execute() {
|
||||||
_btRuntime->setHalt(true);
|
_btRuntime->setHalt(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,11 +62,11 @@ public:
|
||||||
|
|
||||||
virtual bool execute()
|
virtual bool execute()
|
||||||
{
|
{
|
||||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(_picker->hasNext() && !_picker->isPicked()) {
|
if(_picker->hasNext() && !_picker->isPicked()) {
|
||||||
_e->commands.push_back(createCommand(_picker->pickNext()));
|
_e->addCommand(createCommand(_picker->pickNext()));
|
||||||
|
|
||||||
_e->setNoWait(true);
|
_e->setNoWait(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,10 @@
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -54,11 +58,11 @@ bool SleepCommand::execute() {
|
||||||
if(_requestGroup->downloadFinished() || _requestGroup->isHaltRequested()) {
|
if(_requestGroup->downloadFinished() || _requestGroup->isHaltRequested()) {
|
||||||
return true;
|
return true;
|
||||||
} else if(checkPoint.difference(global::wallclock) >= wait) {
|
} else if(checkPoint.difference(global::wallclock) >= wait) {
|
||||||
engine->commands.push_back(nextCommand);
|
engine->addCommand(nextCommand);
|
||||||
nextCommand = 0;
|
nextCommand = 0;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
engine->commands.push_back(this);
|
engine->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "StreamFileAllocationEntry.h"
|
#include "StreamFileAllocationEntry.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,9 @@
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,11 @@
|
||||||
#include "TimeBasedCommand.h"
|
#include "TimeBasedCommand.h"
|
||||||
#include "DownloadEngine.h"
|
#include "DownloadEngine.h"
|
||||||
#include "wallclock.h"
|
#include "wallclock.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -66,7 +71,7 @@ bool TimeBasedCommand::execute()
|
||||||
if(_routineCommand) {
|
if(_routineCommand) {
|
||||||
_e->addRoutineCommand(this);
|
_e->addRoutineCommand(this);
|
||||||
} else {
|
} else {
|
||||||
_e->commands.push_back(this);
|
_e->addCommand(this);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -51,7 +54,7 @@ TimedHaltCommand::~TimedHaltCommand() {}
|
||||||
|
|
||||||
void TimedHaltCommand::preProcess()
|
void TimedHaltCommand::preProcess()
|
||||||
{
|
{
|
||||||
if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
|
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
||||||
_exit = true;
|
_exit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,10 @@
|
||||||
#include "bittorrent_helper.h"
|
#include "bittorrent_helper.h"
|
||||||
#include "a2functional.h"
|
#include "a2functional.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -87,7 +91,7 @@ bool TrackerWatcherCommand::execute() {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
_trackerRequestGroup->setForceHaltRequested(true);
|
_trackerRequestGroup->setForceHaltRequested(true);
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +140,7 @@ bool TrackerWatcherCommand::execute() {
|
||||||
_btAnnounce->resetAnnounce();
|
_btAnnounce->resetAnnounce();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e->commands.push_back(this);
|
e->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +179,7 @@ void TrackerWatcherCommand::processTrackerResponse
|
||||||
(peer->usedBy(), _requestGroup, peer, e, _btRuntime);
|
(peer->usedBy(), _requestGroup, peer, e, _btRuntime);
|
||||||
command->setPeerStorage(_peerStorage);
|
command->setPeerStorage(_peerStorage);
|
||||||
command->setPieceStorage(_pieceStorage);
|
command->setPieceStorage(_pieceStorage);
|
||||||
e->commands.push_back(command);
|
e->addCommand(command);
|
||||||
if(logger->debug()) {
|
if(logger->debug()) {
|
||||||
logger->debug("CUID#%s - Adding new command CUID#%s",
|
logger->debug("CUID#%s - Adding new command CUID#%s",
|
||||||
util::itos(cuid).c_str(),
|
util::itos(cuid).c_str(),
|
||||||
|
|
|
@ -47,6 +47,11 @@
|
||||||
#include "XmlRpcResponse.h"
|
#include "XmlRpcResponse.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "StringFormat.h"
|
#include "StringFormat.h"
|
||||||
|
#include "RequestGroupMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,9 @@
|
||||||
#include "XmlRpcResponse.h"
|
#include "XmlRpcResponse.h"
|
||||||
#include "SegmentMan.h"
|
#include "SegmentMan.h"
|
||||||
#include "TimedHaltCommand.h"
|
#include "TimedHaltCommand.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
# include "bittorrent_helper.h"
|
# include "bittorrent_helper.h"
|
||||||
# include "BtRegistry.h"
|
# include "BtRegistry.h"
|
||||||
|
@ -146,9 +149,9 @@ static BDE addRequestGroup(const SharedHandle<RequestGroup>& group,
|
||||||
bool posGiven, int pos)
|
bool posGiven, int pos)
|
||||||
{
|
{
|
||||||
if(posGiven) {
|
if(posGiven) {
|
||||||
e->_requestGroupMan->insertReservedGroup(pos, group);
|
e->getRequestGroupMan()->insertReservedGroup(pos, group);
|
||||||
} else {
|
} else {
|
||||||
e->_requestGroupMan->addReservedGroup(group);
|
e->getRequestGroupMan()->addReservedGroup(group);
|
||||||
}
|
}
|
||||||
return createGIDResponse(group->getGID());
|
return createGIDResponse(group->getGID());
|
||||||
}
|
}
|
||||||
|
@ -205,7 +208,7 @@ BDE AddUriXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
std::vector<std::string> uris;
|
std::vector<std::string> uris;
|
||||||
extractUris(std::back_inserter(uris), params[0]);
|
extractUris(std::back_inserter(uris), params[0]);
|
||||||
|
|
||||||
SharedHandle<Option> requestOption(new Option(*e->option));
|
SharedHandle<Option> requestOption(new Option(*e->getOption()));
|
||||||
if(hasDictParam(params, 1)) {
|
if(hasDictParam(params, 1)) {
|
||||||
gatherRequestOption(requestOption, params[1]);
|
gatherRequestOption(requestOption, params[1]);
|
||||||
}
|
}
|
||||||
|
@ -239,7 +242,7 @@ BDE AddTorrentXmlRpcMethod::process
|
||||||
if(params.size() > 1 && params[1].isList()) {
|
if(params.size() > 1 && params[1].isList()) {
|
||||||
extractUris(std::back_inserter(uris), params[1]);
|
extractUris(std::back_inserter(uris), params[1]);
|
||||||
}
|
}
|
||||||
SharedHandle<Option> requestOption(new Option(*e->option));
|
SharedHandle<Option> requestOption(new Option(*e->getOption()));
|
||||||
if(hasDictParam(params, 2)) {
|
if(hasDictParam(params, 2)) {
|
||||||
gatherRequestOption(requestOption, params[2]);
|
gatherRequestOption(requestOption, params[2]);
|
||||||
}
|
}
|
||||||
|
@ -270,7 +273,7 @@ BDE AddMetalinkXmlRpcMethod::process
|
||||||
throw DL_ABORT_EX("Metalink data is not provided.");
|
throw DL_ABORT_EX("Metalink data is not provided.");
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedHandle<Option> requestOption(new Option(*e->option));
|
SharedHandle<Option> requestOption(new Option(*e->getOption()));
|
||||||
if(hasDictParam(params, 1)) {
|
if(hasDictParam(params, 1)) {
|
||||||
gatherRequestOption(requestOption, params[1]);
|
gatherRequestOption(requestOption, params[1]);
|
||||||
};
|
};
|
||||||
|
@ -282,9 +285,9 @@ BDE AddMetalinkXmlRpcMethod::process
|
||||||
createRequestGroupForMetalink(result, requestOption, params[0].s());
|
createRequestGroupForMetalink(result, requestOption, params[0].s());
|
||||||
if(!result.empty()) {
|
if(!result.empty()) {
|
||||||
if(posGiven) {
|
if(posGiven) {
|
||||||
e->_requestGroupMan->insertReservedGroup(pos, result);
|
e->getRequestGroupMan()->insertReservedGroup(pos, result);
|
||||||
} else {
|
} else {
|
||||||
e->_requestGroupMan->addReservedGroup(result);
|
e->getRequestGroupMan()->addReservedGroup(result);
|
||||||
}
|
}
|
||||||
BDE gids = BDE::list();
|
BDE gids = BDE::list();
|
||||||
for(std::vector<SharedHandle<RequestGroup> >::const_iterator i =
|
for(std::vector<SharedHandle<RequestGroup> >::const_iterator i =
|
||||||
|
@ -310,17 +313,18 @@ static BDE removeDownload
|
||||||
|
|
||||||
gid_t gid = util::parseLLInt(params[0].s());
|
gid_t gid = util::parseLLInt(params[0].s());
|
||||||
|
|
||||||
SharedHandle<RequestGroup> group = e->_requestGroupMan->findRequestGroup(gid);
|
SharedHandle<RequestGroup> group =
|
||||||
|
e->getRequestGroupMan()->findRequestGroup(gid);
|
||||||
|
|
||||||
if(group.isNull()) {
|
if(group.isNull()) {
|
||||||
group = e->_requestGroupMan->findReservedGroup(gid);
|
group = e->getRequestGroupMan()->findReservedGroup(gid);
|
||||||
if(group.isNull()) {
|
if(group.isNull()) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(StringFormat("Active Download not found for GID#%s",
|
(StringFormat("Active Download not found for GID#%s",
|
||||||
util::itos(gid).c_str()).str());
|
util::itos(gid).c_str()).str());
|
||||||
}
|
}
|
||||||
if(group->isDependencyResolved()) {
|
if(group->isDependencyResolved()) {
|
||||||
e->_requestGroupMan->removeReservedGroup(gid);
|
e->getRequestGroupMan()->removeReservedGroup(gid);
|
||||||
} else {
|
} else {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(StringFormat("GID#%s cannot be removed now",
|
(StringFormat("GID#%s cannot be removed now",
|
||||||
|
@ -383,10 +387,11 @@ static BDE pauseDownload
|
||||||
}
|
}
|
||||||
gid_t gid = util::parseLLInt(params[0].s());
|
gid_t gid = util::parseLLInt(params[0].s());
|
||||||
bool reserved = false;
|
bool reserved = false;
|
||||||
SharedHandle<RequestGroup> group = e->_requestGroupMan->findRequestGroup(gid);
|
SharedHandle<RequestGroup> group =
|
||||||
|
e->getRequestGroupMan()->findRequestGroup(gid);
|
||||||
if(group.isNull()) {
|
if(group.isNull()) {
|
||||||
reserved = true;
|
reserved = true;
|
||||||
group = e->_requestGroupMan->findReservedGroup(gid);
|
group = e->getRequestGroupMan()->findReservedGroup(gid);
|
||||||
}
|
}
|
||||||
if(!group.isNull() && pauseRequestGroup(group, reserved, forcePause)) {
|
if(!group.isNull() && pauseRequestGroup(group, reserved, forcePause)) {
|
||||||
return createGIDResponse(gid);
|
return createGIDResponse(gid);
|
||||||
|
@ -420,10 +425,10 @@ static BDE pauseAllDownloads
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e, bool forcePause)
|
(const XmlRpcRequest& req, DownloadEngine* e, bool forcePause)
|
||||||
{
|
{
|
||||||
const std::deque<SharedHandle<RequestGroup> >& groups =
|
const std::deque<SharedHandle<RequestGroup> >& groups =
|
||||||
e->_requestGroupMan->getRequestGroups();
|
e->getRequestGroupMan()->getRequestGroups();
|
||||||
pauseRequestGroups(groups.begin(), groups.end(), false, forcePause);
|
pauseRequestGroups(groups.begin(), groups.end(), false, forcePause);
|
||||||
const std::deque<SharedHandle<RequestGroup> >& reservedGroups =
|
const std::deque<SharedHandle<RequestGroup> >& reservedGroups =
|
||||||
e->_requestGroupMan->getReservedGroups();
|
e->getRequestGroupMan()->getReservedGroups();
|
||||||
pauseRequestGroups(reservedGroups.begin(), reservedGroups.end(),
|
pauseRequestGroups(reservedGroups.begin(), reservedGroups.end(),
|
||||||
true, forcePause);
|
true, forcePause);
|
||||||
return BDE_OK;
|
return BDE_OK;
|
||||||
|
@ -448,14 +453,15 @@ BDE UnpauseXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED);
|
throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED);
|
||||||
}
|
}
|
||||||
gid_t gid = util::parseLLInt(params[0].s());
|
gid_t gid = util::parseLLInt(params[0].s());
|
||||||
SharedHandle<RequestGroup> group =e->_requestGroupMan->findReservedGroup(gid);
|
SharedHandle<RequestGroup> group =
|
||||||
|
e->getRequestGroupMan()->findReservedGroup(gid);
|
||||||
if(group.isNull() || !group->isPauseRequested()) {
|
if(group.isNull() || !group->isPauseRequested()) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(StringFormat("GID#%s cannot be unpaused now",
|
(StringFormat("GID#%s cannot be unpaused now",
|
||||||
util::itos(gid).c_str()).str());
|
util::itos(gid).c_str()).str());
|
||||||
} else {
|
} else {
|
||||||
group->setPauseRequested(false);
|
group->setPauseRequested(false);
|
||||||
e->_requestGroupMan->requestQueueCheck();
|
e->getRequestGroupMan()->requestQueueCheck();
|
||||||
}
|
}
|
||||||
return createGIDResponse(gid);
|
return createGIDResponse(gid);
|
||||||
}
|
}
|
||||||
|
@ -463,11 +469,11 @@ BDE UnpauseXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
BDE UnpauseAllXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
BDE UnpauseAllXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
const std::deque<SharedHandle<RequestGroup> >& groups =
|
const std::deque<SharedHandle<RequestGroup> >& groups =
|
||||||
e->_requestGroupMan->getReservedGroups();
|
e->getRequestGroupMan()->getReservedGroups();
|
||||||
std::for_each(groups.begin(), groups.end(),
|
std::for_each(groups.begin(), groups.end(),
|
||||||
std::bind2nd(mem_fun_sh(&RequestGroup::setPauseRequested),
|
std::bind2nd(mem_fun_sh(&RequestGroup::setPauseRequested),
|
||||||
false));
|
false));
|
||||||
e->_requestGroupMan->requestQueueCheck();
|
e->getRequestGroupMan()->requestQueueCheck();
|
||||||
return BDE_OK;
|
return BDE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,10 +716,11 @@ BDE GetFilesXmlRpcMethod::process
|
||||||
gid_t gid = util::parseLLInt(params[0].s());
|
gid_t gid = util::parseLLInt(params[0].s());
|
||||||
|
|
||||||
BDE files = BDE::list();
|
BDE files = BDE::list();
|
||||||
SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
|
SharedHandle<RequestGroup> group =
|
||||||
|
findRequestGroup(e->getRequestGroupMan(), gid);
|
||||||
if(group.isNull()) {
|
if(group.isNull()) {
|
||||||
SharedHandle<DownloadResult> dr =
|
SharedHandle<DownloadResult> dr =
|
||||||
e->_requestGroupMan->findDownloadResult(gid);
|
e->getRequestGroupMan()->findDownloadResult(gid);
|
||||||
if(dr.isNull()) {
|
if(dr.isNull()) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(StringFormat("No file data is available for GID#%s",
|
(StringFormat("No file data is available for GID#%s",
|
||||||
|
@ -741,7 +748,8 @@ BDE GetUrisXmlRpcMethod::process
|
||||||
|
|
||||||
gid_t gid = util::parseLLInt(params[0].s());
|
gid_t gid = util::parseLLInt(params[0].s());
|
||||||
|
|
||||||
SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
|
SharedHandle<RequestGroup> group =
|
||||||
|
findRequestGroup(e->getRequestGroupMan(), gid);
|
||||||
if(group.isNull()) {
|
if(group.isNull()) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(StringFormat("No URI data is available for GID#%s",
|
(StringFormat("No URI data is available for GID#%s",
|
||||||
|
@ -768,7 +776,8 @@ BDE GetPeersXmlRpcMethod::process
|
||||||
|
|
||||||
gid_t gid = util::parseLLInt(params[0].s());
|
gid_t gid = util::parseLLInt(params[0].s());
|
||||||
|
|
||||||
SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
|
SharedHandle<RequestGroup> group =
|
||||||
|
findRequestGroup(e->getRequestGroupMan(), gid);
|
||||||
if(group.isNull()) {
|
if(group.isNull()) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(StringFormat("No peer data is available for GID#%s",
|
(StringFormat("No peer data is available for GID#%s",
|
||||||
|
@ -796,14 +805,15 @@ BDE TellStatusXmlRpcMethod::process
|
||||||
|
|
||||||
gid_t gid = util::parseLLInt(params[0].s());
|
gid_t gid = util::parseLLInt(params[0].s());
|
||||||
|
|
||||||
SharedHandle<RequestGroup> group = e->_requestGroupMan->findRequestGroup(gid);
|
SharedHandle<RequestGroup> group =
|
||||||
|
e->getRequestGroupMan()->findRequestGroup(gid);
|
||||||
|
|
||||||
BDE entryDict = BDE::dict();
|
BDE entryDict = BDE::dict();
|
||||||
if(group.isNull()) {
|
if(group.isNull()) {
|
||||||
group = e->_requestGroupMan->findReservedGroup(gid);
|
group = e->getRequestGroupMan()->findReservedGroup(gid);
|
||||||
if(group.isNull()) {
|
if(group.isNull()) {
|
||||||
SharedHandle<DownloadResult> ds =
|
SharedHandle<DownloadResult> ds =
|
||||||
e->_requestGroupMan->findDownloadResult(gid);
|
e->getRequestGroupMan()->findDownloadResult(gid);
|
||||||
if(ds.isNull()) {
|
if(ds.isNull()) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(StringFormat("No such download for GID#%s",
|
(StringFormat("No such download for GID#%s",
|
||||||
|
@ -830,7 +840,7 @@ BDE TellActiveXmlRpcMethod::process
|
||||||
{
|
{
|
||||||
BDE list = BDE::list();
|
BDE list = BDE::list();
|
||||||
const std::deque<SharedHandle<RequestGroup> >& groups =
|
const std::deque<SharedHandle<RequestGroup> >& groups =
|
||||||
e->_requestGroupMan->getRequestGroups();
|
e->getRequestGroupMan()->getRequestGroups();
|
||||||
for(std::deque<SharedHandle<RequestGroup> >::const_iterator i =
|
for(std::deque<SharedHandle<RequestGroup> >::const_iterator i =
|
||||||
groups.begin(), eoi = groups.end(); i != eoi; ++i) {
|
groups.begin(), eoi = groups.end(); i != eoi; ++i) {
|
||||||
BDE entryDict = BDE::dict();
|
BDE entryDict = BDE::dict();
|
||||||
|
@ -844,7 +854,7 @@ BDE TellActiveXmlRpcMethod::process
|
||||||
const std::deque<SharedHandle<RequestGroup> >&
|
const std::deque<SharedHandle<RequestGroup> >&
|
||||||
TellWaitingXmlRpcMethod::getItems(DownloadEngine* e) const
|
TellWaitingXmlRpcMethod::getItems(DownloadEngine* e) const
|
||||||
{
|
{
|
||||||
return e->_requestGroupMan->getReservedGroups();
|
return e->getRequestGroupMan()->getReservedGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TellWaitingXmlRpcMethod::createEntry
|
void TellWaitingXmlRpcMethod::createEntry
|
||||||
|
@ -862,7 +872,7 @@ void TellWaitingXmlRpcMethod::createEntry
|
||||||
const std::deque<SharedHandle<DownloadResult> >&
|
const std::deque<SharedHandle<DownloadResult> >&
|
||||||
TellStoppedXmlRpcMethod::getItems(DownloadEngine* e) const
|
TellStoppedXmlRpcMethod::getItems(DownloadEngine* e) const
|
||||||
{
|
{
|
||||||
return e->_requestGroupMan->getDownloadResults();
|
return e->getRequestGroupMan()->getDownloadResults();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TellStoppedXmlRpcMethod::createEntry
|
void TellStoppedXmlRpcMethod::createEntry
|
||||||
|
@ -875,7 +885,7 @@ void TellStoppedXmlRpcMethod::createEntry
|
||||||
BDE PurgeDownloadResultXmlRpcMethod::process
|
BDE PurgeDownloadResultXmlRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
e->_requestGroupMan->purgeDownloadResult();
|
e->getRequestGroupMan()->purgeDownloadResult();
|
||||||
return BDE_OK;
|
return BDE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -889,7 +899,8 @@ BDE ChangeOptionXmlRpcMethod::process
|
||||||
}
|
}
|
||||||
gid_t gid = util::parseLLInt(params[0].s());
|
gid_t gid = util::parseLLInt(params[0].s());
|
||||||
|
|
||||||
SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
|
SharedHandle<RequestGroup> group =
|
||||||
|
findRequestGroup(e->getRequestGroupMan(), gid);
|
||||||
if(group.isNull()) {
|
if(group.isNull()) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(StringFormat("Cannot change option for GID#%s",
|
(StringFormat("Cannot change option for GID#%s",
|
||||||
|
@ -928,20 +939,20 @@ BDE ChangeGlobalOptionXmlRpcMethod::process
|
||||||
}
|
}
|
||||||
SharedHandle<Option> option(new Option());
|
SharedHandle<Option> option(new Option());
|
||||||
gatherChangeableGlobalOption(option, params[0]);
|
gatherChangeableGlobalOption(option, params[0]);
|
||||||
applyChangeableGlobalOption(e->option, option.get());
|
applyChangeableGlobalOption(e->getOption(), option.get());
|
||||||
|
|
||||||
if(option->defined(PREF_MAX_OVERALL_DOWNLOAD_LIMIT)) {
|
if(option->defined(PREF_MAX_OVERALL_DOWNLOAD_LIMIT)) {
|
||||||
e->_requestGroupMan->setMaxOverallDownloadSpeedLimit
|
e->getRequestGroupMan()->setMaxOverallDownloadSpeedLimit
|
||||||
(option->getAsInt(PREF_MAX_OVERALL_DOWNLOAD_LIMIT));
|
(option->getAsInt(PREF_MAX_OVERALL_DOWNLOAD_LIMIT));
|
||||||
}
|
}
|
||||||
if(option->defined(PREF_MAX_OVERALL_UPLOAD_LIMIT)) {
|
if(option->defined(PREF_MAX_OVERALL_UPLOAD_LIMIT)) {
|
||||||
e->_requestGroupMan->setMaxOverallUploadSpeedLimit
|
e->getRequestGroupMan()->setMaxOverallUploadSpeedLimit
|
||||||
(option->getAsInt(PREF_MAX_OVERALL_UPLOAD_LIMIT));
|
(option->getAsInt(PREF_MAX_OVERALL_UPLOAD_LIMIT));
|
||||||
}
|
}
|
||||||
if(option->defined(PREF_MAX_CONCURRENT_DOWNLOADS)) {
|
if(option->defined(PREF_MAX_CONCURRENT_DOWNLOADS)) {
|
||||||
e->_requestGroupMan->setMaxSimultaneousDownloads
|
e->getRequestGroupMan()->setMaxSimultaneousDownloads
|
||||||
(option->getAsInt(PREF_MAX_CONCURRENT_DOWNLOADS));
|
(option->getAsInt(PREF_MAX_CONCURRENT_DOWNLOADS));
|
||||||
e->_requestGroupMan->requestQueueCheck();
|
e->getRequestGroupMan()->requestQueueCheck();
|
||||||
}
|
}
|
||||||
return BDE_OK;
|
return BDE_OK;
|
||||||
}
|
}
|
||||||
|
@ -985,7 +996,8 @@ BDE GetOptionXmlRpcMethod::process
|
||||||
}
|
}
|
||||||
gid_t gid = util::parseLLInt(params[0].s());
|
gid_t gid = util::parseLLInt(params[0].s());
|
||||||
|
|
||||||
SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
|
SharedHandle<RequestGroup> group =
|
||||||
|
findRequestGroup(e->getRequestGroupMan(), gid);
|
||||||
if(group.isNull()) {
|
if(group.isNull()) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(StringFormat("Cannot get option for GID#%s",
|
(StringFormat("Cannot get option for GID#%s",
|
||||||
|
@ -1001,8 +1013,8 @@ BDE GetGlobalOptionXmlRpcMethod::process
|
||||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||||
{
|
{
|
||||||
BDE result = BDE::dict();
|
BDE result = BDE::dict();
|
||||||
for(std::map<std::string, std::string>::const_iterator i = e->option->begin(),
|
for(std::map<std::string, std::string>::const_iterator i =
|
||||||
eoi = e->option->end(); i != eoi; ++i) {
|
e->getOption()->begin(), eoi = e->getOption()->end(); i != eoi; ++i) {
|
||||||
SharedHandle<OptionHandler> h = _optionParser->findByName((*i).first);
|
SharedHandle<OptionHandler> h = _optionParser->findByName((*i).first);
|
||||||
if(!h.isNull() && !h->isHidden()) {
|
if(!h.isNull() && !h->isHidden()) {
|
||||||
result[(*i).first] = (*i).second;
|
result[(*i).first] = (*i).second;
|
||||||
|
@ -1035,7 +1047,7 @@ BDE ChangePositionXmlRpcMethod::process
|
||||||
throw DL_ABORT_EX("Illegal argument.");
|
throw DL_ABORT_EX("Illegal argument.");
|
||||||
}
|
}
|
||||||
size_t destPos =
|
size_t destPos =
|
||||||
e->_requestGroupMan->changeReservedGroupPosition(gid, pos, how);
|
e->getRequestGroupMan()->changeReservedGroupPosition(gid, pos, how);
|
||||||
BDE result(destPos);
|
BDE result(destPos);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1058,7 +1070,8 @@ BDE GetServersXmlRpcMethod::process
|
||||||
throw DL_ABORT_EX("Bad request");
|
throw DL_ABORT_EX("Bad request");
|
||||||
}
|
}
|
||||||
gid_t gid = util::parseLLInt(params[0].s());
|
gid_t gid = util::parseLLInt(params[0].s());
|
||||||
SharedHandle<RequestGroup> group = e->_requestGroupMan->findRequestGroup(gid);
|
SharedHandle<RequestGroup> group =
|
||||||
|
e->getRequestGroupMan()->findRequestGroup(gid);
|
||||||
if(group.isNull()) {
|
if(group.isNull()) {
|
||||||
throw DL_ABORT_EX(StringFormat("No active download for GID#%s",
|
throw DL_ABORT_EX(StringFormat("No active download for GID#%s",
|
||||||
util::itos(gid).c_str()).str());
|
util::itos(gid).c_str()).str());
|
||||||
|
@ -1112,7 +1125,8 @@ BDE ChangeUriXmlRpcMethod::process
|
||||||
size_t index = params[1].i()-1;
|
size_t index = params[1].i()-1;
|
||||||
const BDE& deluris = params[2];
|
const BDE& deluris = params[2];
|
||||||
const BDE& adduris = params[3];
|
const BDE& adduris = params[3];
|
||||||
SharedHandle<RequestGroup> group = findRequestGroup(e->_requestGroupMan, gid);
|
SharedHandle<RequestGroup> group =
|
||||||
|
findRequestGroup(e->getRequestGroupMan(), gid);
|
||||||
if(group.isNull()) {
|
if(group.isNull()) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(StringFormat("Cannot remove URIs from GID#%s",
|
(StringFormat("Cannot remove URIs from GID#%s",
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "array_fun.h"
|
#include "array_fun.h"
|
||||||
#include "download_helper.h"
|
#include "download_helper.h"
|
||||||
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "CheckIntegrityEntry.h"
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
# include "BtRegistry.h"
|
# include "BtRegistry.h"
|
||||||
# include "BtRuntime.h"
|
# include "BtRuntime.h"
|
||||||
|
@ -92,15 +94,15 @@ public:
|
||||||
_option.reset(new Option());
|
_option.reset(new Option());
|
||||||
_option->put(PREF_DIR, "/tmp");
|
_option->put(PREF_DIR, "/tmp");
|
||||||
_option->put(PREF_SEGMENT_SIZE, "1048576");
|
_option->put(PREF_SEGMENT_SIZE, "1048576");
|
||||||
_e.reset(new DownloadEngine(SharedHandle<EventPoll>(new SelectEventPoll())));
|
_e.reset
|
||||||
_e->option = _option.get();
|
(new DownloadEngine(SharedHandle<EventPoll>(new SelectEventPoll())));
|
||||||
_e->_requestGroupMan.reset
|
_e->setOption(_option.get());
|
||||||
(new RequestGroupMan(std::vector<SharedHandle<RequestGroup> >(),
|
_e->setRequestGroupMan
|
||||||
1, _option.get()));
|
(SharedHandle<RequestGroupMan>
|
||||||
|
(new RequestGroupMan(std::vector<SharedHandle<RequestGroup> >(),
|
||||||
|
1, _option.get())));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tearDown() {}
|
|
||||||
|
|
||||||
void testAddUri();
|
void testAddUri();
|
||||||
void testAddUri_withoutUri();
|
void testAddUri_withoutUri();
|
||||||
void testAddUri_notUri();
|
void testAddUri_notUri();
|
||||||
|
@ -159,10 +161,11 @@ void XmlRpcMethodTest::testAddUri()
|
||||||
XmlRpcResponse res = m.execute(req, _e.get());
|
XmlRpcResponse res = m.execute(req, _e.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
||||||
const std::deque<SharedHandle<RequestGroup> > rgs =
|
const std::deque<SharedHandle<RequestGroup> > rgs =
|
||||||
_e->_requestGroupMan->getReservedGroups();
|
_e->getRequestGroupMan()->getReservedGroups();
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)1, rgs.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)1, rgs.size());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/"),
|
CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/"),
|
||||||
rgs.front()->getDownloadContext()->getFirstFileEntry()->getRemainingUris().front());
|
rgs.front()->getDownloadContext()->
|
||||||
|
getFirstFileEntry()->getRemainingUris().front());
|
||||||
}
|
}
|
||||||
// with options
|
// with options
|
||||||
BDE opt = BDE::dict();
|
BDE opt = BDE::dict();
|
||||||
|
@ -172,7 +175,7 @@ void XmlRpcMethodTest::testAddUri()
|
||||||
XmlRpcResponse res = m.execute(req, _e.get());
|
XmlRpcResponse res = m.execute(req, _e.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/sink"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/sink"),
|
||||||
_e->_requestGroupMan->findReservedGroup(2)->
|
_e->getRequestGroupMan()->findReservedGroup(2)->
|
||||||
getDownloadContext()->getDir());
|
getDownloadContext()->getDir());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,7 +228,8 @@ void XmlRpcMethodTest::testAddUri_withPosition()
|
||||||
m.execute(req2, _e.get());
|
m.execute(req2, _e.get());
|
||||||
|
|
||||||
std::string uri =
|
std::string uri =
|
||||||
_e->_requestGroupMan->getReservedGroups()[0]->getDownloadContext()->getFirstFileEntry()->getRemainingUris()[0];
|
_e->getRequestGroupMan()->getReservedGroups()[0]->
|
||||||
|
getDownloadContext()->getFirstFileEntry()->getRemainingUris()[0];
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://uri2"), uri);
|
CPPUNIT_ASSERT_EQUAL(std::string("http://uri2"), uri);
|
||||||
}
|
}
|
||||||
|
@ -256,13 +260,17 @@ void XmlRpcMethodTest::testAddTorrent()
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("1"), res._param.s());
|
CPPUNIT_ASSERT_EQUAL(std::string("1"), res._param.s());
|
||||||
|
|
||||||
SharedHandle<RequestGroup> group = _e->_requestGroupMan->findReservedGroup(1);
|
SharedHandle<RequestGroup> group =
|
||||||
|
_e->getRequestGroupMan()->findReservedGroup(1);
|
||||||
CPPUNIT_ASSERT(!group.isNull());
|
CPPUNIT_ASSERT(!group.isNull());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-0.8.2.tar.bz2"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-0.8.2.tar.bz2"),
|
||||||
group->getFirstFilePath());
|
group->getFirstFilePath());
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)1, group->getDownloadContext()->getFirstFileEntry()->getRemainingUris().size());
|
CPPUNIT_ASSERT_EQUAL((size_t)1,
|
||||||
|
group->getDownloadContext()->getFirstFileEntry()->
|
||||||
|
getRemainingUris().size());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/aria2-0.8.2.tar.bz2"),
|
CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/aria2-0.8.2.tar.bz2"),
|
||||||
group->getDownloadContext()->getFirstFileEntry()->getRemainingUris()[0]);
|
group->getDownloadContext()->getFirstFileEntry()->
|
||||||
|
getRemainingUris()[0]);
|
||||||
}
|
}
|
||||||
// with options
|
// with options
|
||||||
BDE opt = BDE::dict();
|
BDE opt = BDE::dict();
|
||||||
|
@ -272,7 +280,8 @@ void XmlRpcMethodTest::testAddTorrent()
|
||||||
XmlRpcResponse res = m.execute(req, _e.get());
|
XmlRpcResponse res = m.execute(req, _e.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/sink/aria2-0.8.2.tar.bz2"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/sink/aria2-0.8.2.tar.bz2"),
|
||||||
_e->_requestGroupMan->findReservedGroup(2)->getFirstFilePath());
|
_e->getRequestGroupMan()->findReservedGroup(2)->
|
||||||
|
getFirstFilePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +320,7 @@ void XmlRpcMethodTest::testAddTorrent_withPosition()
|
||||||
m.execute(req2, _e.get());
|
m.execute(req2, _e.get());
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)1,
|
CPPUNIT_ASSERT_EQUAL((size_t)1,
|
||||||
_e->_requestGroupMan->getReservedGroups()[0]->
|
_e->getRequestGroupMan()->getReservedGroups()[0]->
|
||||||
getDownloadContext()->getFileEntries().size());
|
getDownloadContext()->getFileEntries().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,11 +339,13 @@ void XmlRpcMethodTest::testAddMetalink()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("1"), res._param[0].s());
|
CPPUNIT_ASSERT_EQUAL(std::string("1"), res._param[0].s());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("2"), res._param[1].s());
|
CPPUNIT_ASSERT_EQUAL(std::string("2"), res._param[1].s());
|
||||||
|
|
||||||
SharedHandle<RequestGroup> tar = _e->_requestGroupMan->findReservedGroup(1);
|
SharedHandle<RequestGroup> tar =
|
||||||
|
_e->getRequestGroupMan()->findReservedGroup(1);
|
||||||
CPPUNIT_ASSERT(!tar.isNull());
|
CPPUNIT_ASSERT(!tar.isNull());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.tar.bz2"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.tar.bz2"),
|
||||||
tar->getFirstFilePath());
|
tar->getFirstFilePath());
|
||||||
SharedHandle<RequestGroup> deb = _e->_requestGroupMan->findReservedGroup(2);
|
SharedHandle<RequestGroup> deb =
|
||||||
|
_e->getRequestGroupMan()->findReservedGroup(2);
|
||||||
CPPUNIT_ASSERT(!deb.isNull());
|
CPPUNIT_ASSERT(!deb.isNull());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.deb"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.deb"),
|
||||||
deb->getFirstFilePath());
|
deb->getFirstFilePath());
|
||||||
|
@ -347,7 +358,8 @@ void XmlRpcMethodTest::testAddMetalink()
|
||||||
XmlRpcResponse res = m.execute(req, _e.get());
|
XmlRpcResponse res = m.execute(req, _e.get());
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/sink/aria2-5.0.0.tar.bz2"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/sink/aria2-5.0.0.tar.bz2"),
|
||||||
_e->_requestGroupMan->findReservedGroup(3)->getFirstFilePath());
|
_e->getRequestGroupMan()->findReservedGroup(3)->
|
||||||
|
getFirstFilePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +398,7 @@ void XmlRpcMethodTest::testAddMetalink_withPosition()
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res2._code);
|
CPPUNIT_ASSERT_EQUAL(0, res2._code);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.tar.bz2"),
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.tar.bz2"),
|
||||||
_e->_requestGroupMan->getReservedGroups()[0]->
|
_e->getRequestGroupMan()->getReservedGroups()[0]->
|
||||||
getFirstFilePath());
|
getFirstFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +407,7 @@ void XmlRpcMethodTest::testAddMetalink_withPosition()
|
||||||
void XmlRpcMethodTest::testChangeOption()
|
void XmlRpcMethodTest::testChangeOption()
|
||||||
{
|
{
|
||||||
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
||||||
_e->_requestGroupMan->addReservedGroup(group);
|
_e->getRequestGroupMan()->addReservedGroup(group);
|
||||||
|
|
||||||
ChangeOptionXmlRpcMethod m;
|
ChangeOptionXmlRpcMethod m;
|
||||||
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
|
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
|
||||||
|
@ -438,7 +450,7 @@ void XmlRpcMethodTest::testChangeOption()
|
||||||
void XmlRpcMethodTest::testChangeOption_withBadOption()
|
void XmlRpcMethodTest::testChangeOption_withBadOption()
|
||||||
{
|
{
|
||||||
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
||||||
_e->_requestGroupMan->addReservedGroup(group);
|
_e->getRequestGroupMan()->addReservedGroup(group);
|
||||||
|
|
||||||
ChangeOptionXmlRpcMethod m;
|
ChangeOptionXmlRpcMethod m;
|
||||||
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
|
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
|
||||||
|
@ -453,7 +465,7 @@ void XmlRpcMethodTest::testChangeOption_withBadOption()
|
||||||
void XmlRpcMethodTest::testChangeOption_withNotAllowedOption()
|
void XmlRpcMethodTest::testChangeOption_withNotAllowedOption()
|
||||||
{
|
{
|
||||||
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
||||||
_e->_requestGroupMan->addReservedGroup(group);
|
_e->getRequestGroupMan()->addReservedGroup(group);
|
||||||
|
|
||||||
ChangeOptionXmlRpcMethod m;
|
ChangeOptionXmlRpcMethod m;
|
||||||
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
|
XmlRpcRequest req(ChangeOptionXmlRpcMethod::getMethodName(), BDE::list());
|
||||||
|
@ -476,7 +488,8 @@ void XmlRpcMethodTest::testChangeOption_withoutGid()
|
||||||
void XmlRpcMethodTest::testChangeGlobalOption()
|
void XmlRpcMethodTest::testChangeGlobalOption()
|
||||||
{
|
{
|
||||||
ChangeGlobalOptionXmlRpcMethod m;
|
ChangeGlobalOptionXmlRpcMethod m;
|
||||||
XmlRpcRequest req(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
|
XmlRpcRequest req
|
||||||
|
(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
|
||||||
BDE opt = BDE::dict();
|
BDE opt = BDE::dict();
|
||||||
opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("100K");
|
opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("100K");
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
|
@ -486,22 +499,25 @@ void XmlRpcMethodTest::testChangeGlobalOption()
|
||||||
XmlRpcResponse res = m.execute(req, _e.get());
|
XmlRpcResponse res = m.execute(req, _e.get());
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)100*1024,
|
CPPUNIT_ASSERT_EQUAL
|
||||||
_e->_requestGroupMan->getMaxOverallDownloadSpeedLimit());
|
((unsigned int)100*1024,
|
||||||
|
_e->getRequestGroupMan()->getMaxOverallDownloadSpeedLimit());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("102400"),
|
CPPUNIT_ASSERT_EQUAL(std::string("102400"),
|
||||||
_e->option->get(PREF_MAX_OVERALL_DOWNLOAD_LIMIT));
|
_e->getOption()->get(PREF_MAX_OVERALL_DOWNLOAD_LIMIT));
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
CPPUNIT_ASSERT_EQUAL((unsigned int)50*1024,
|
CPPUNIT_ASSERT_EQUAL
|
||||||
_e->_requestGroupMan->getMaxOverallUploadSpeedLimit());
|
((unsigned int)50*1024,
|
||||||
|
_e->getRequestGroupMan()->getMaxOverallUploadSpeedLimit());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("51200"),
|
CPPUNIT_ASSERT_EQUAL(std::string("51200"),
|
||||||
_e->option->get(PREF_MAX_OVERALL_UPLOAD_LIMIT));
|
_e->getOption()->get(PREF_MAX_OVERALL_UPLOAD_LIMIT));
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testChangeGlobalOption_withBadOption()
|
void XmlRpcMethodTest::testChangeGlobalOption_withBadOption()
|
||||||
{
|
{
|
||||||
ChangeGlobalOptionXmlRpcMethod m;
|
ChangeGlobalOptionXmlRpcMethod m;
|
||||||
XmlRpcRequest req(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
|
XmlRpcRequest req
|
||||||
|
(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
|
||||||
BDE opt = BDE::dict();
|
BDE opt = BDE::dict();
|
||||||
opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("badvalue");
|
opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("badvalue");
|
||||||
req._params << opt;
|
req._params << opt;
|
||||||
|
@ -512,7 +528,8 @@ void XmlRpcMethodTest::testChangeGlobalOption_withBadOption()
|
||||||
void XmlRpcMethodTest::testChangeGlobalOption_withNotAllowedOption()
|
void XmlRpcMethodTest::testChangeGlobalOption_withNotAllowedOption()
|
||||||
{
|
{
|
||||||
ChangeGlobalOptionXmlRpcMethod m;
|
ChangeGlobalOptionXmlRpcMethod m;
|
||||||
XmlRpcRequest req(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
|
XmlRpcRequest req
|
||||||
|
(ChangeGlobalOptionXmlRpcMethod::getMethodName(), BDE::list());
|
||||||
BDE opt = BDE::dict();
|
BDE opt = BDE::dict();
|
||||||
opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("100K");
|
opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("100K");
|
||||||
req._params << opt;
|
req._params << opt;
|
||||||
|
@ -756,9 +773,9 @@ void XmlRpcMethodTest::testGatherBitTorrentMetadata()
|
||||||
|
|
||||||
void XmlRpcMethodTest::testChangePosition()
|
void XmlRpcMethodTest::testChangePosition()
|
||||||
{
|
{
|
||||||
_e->_requestGroupMan->addReservedGroup
|
_e->getRequestGroupMan()->addReservedGroup
|
||||||
(SharedHandle<RequestGroup>(new RequestGroup(_option)));
|
(SharedHandle<RequestGroup>(new RequestGroup(_option)));
|
||||||
_e->_requestGroupMan->addReservedGroup
|
_e->getRequestGroupMan()->addReservedGroup
|
||||||
(SharedHandle<RequestGroup>(new RequestGroup(_option)));
|
(SharedHandle<RequestGroup>(new RequestGroup(_option)));
|
||||||
|
|
||||||
ChangePositionXmlRpcMethod m;
|
ChangePositionXmlRpcMethod m;
|
||||||
|
@ -770,7 +787,7 @@ void XmlRpcMethodTest::testChangePosition()
|
||||||
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
CPPUNIT_ASSERT_EQUAL(0, res._code);
|
||||||
CPPUNIT_ASSERT_EQUAL((int64_t)1, res._param.i());
|
CPPUNIT_ASSERT_EQUAL((int64_t)1, res._param.i());
|
||||||
CPPUNIT_ASSERT_EQUAL
|
CPPUNIT_ASSERT_EQUAL
|
||||||
((gid_t)1, _e->_requestGroupMan->getReservedGroups()[1]->getGID());
|
((gid_t)1, _e->getRequestGroupMan()->getReservedGroups()[1]->getGID());
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlRpcMethodTest::testChangePosition_fail()
|
void XmlRpcMethodTest::testChangePosition_fail()
|
||||||
|
@ -799,7 +816,7 @@ void XmlRpcMethodTest::testChangeUri()
|
||||||
dctx->setFileEntries(&files[0], &files[3]);
|
dctx->setFileEntries(&files[0], &files[3]);
|
||||||
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
||||||
group->setDownloadContext(dctx);
|
group->setDownloadContext(dctx);
|
||||||
_e->_requestGroupMan->addReservedGroup(group);
|
_e->getRequestGroupMan()->addReservedGroup(group);
|
||||||
|
|
||||||
ChangeUriXmlRpcMethod m;
|
ChangeUriXmlRpcMethod m;
|
||||||
XmlRpcRequest req(ChangeUriXmlRpcMethod::getMethodName(), BDE::list());
|
XmlRpcRequest req(ChangeUriXmlRpcMethod::getMethodName(), BDE::list());
|
||||||
|
@ -869,7 +886,7 @@ void XmlRpcMethodTest::testChangeUri_fail()
|
||||||
dctx->setFileEntries(&files[0], &files[3]);
|
dctx->setFileEntries(&files[0], &files[3]);
|
||||||
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
SharedHandle<RequestGroup> group(new RequestGroup(_option));
|
||||||
group->setDownloadContext(dctx);
|
group->setDownloadContext(dctx);
|
||||||
_e->_requestGroupMan->addReservedGroup(group);
|
_e->getRequestGroupMan()->addReservedGroup(group);
|
||||||
|
|
||||||
ChangeUriXmlRpcMethod m;
|
ChangeUriXmlRpcMethod m;
|
||||||
XmlRpcRequest req(ChangeUriXmlRpcMethod::getMethodName(), BDE::list());
|
XmlRpcRequest req(ChangeUriXmlRpcMethod::getMethodName(), BDE::list());
|
||||||
|
@ -933,7 +950,7 @@ void XmlRpcMethodTest::testPause()
|
||||||
std::vector<SharedHandle<RequestGroup> > groups;
|
std::vector<SharedHandle<RequestGroup> > groups;
|
||||||
createRequestGroupForUri(groups, _option, uris);
|
createRequestGroupForUri(groups, _option, uris);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)3, groups.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)3, groups.size());
|
||||||
_e->_requestGroupMan->addReservedGroup(groups);
|
_e->getRequestGroupMan()->addReservedGroup(groups);
|
||||||
{
|
{
|
||||||
PauseXmlRpcMethod m;
|
PauseXmlRpcMethod m;
|
||||||
XmlRpcRequest req(PauseXmlRpcMethod::getMethodName(), BDE::list());
|
XmlRpcRequest req(PauseXmlRpcMethod::getMethodName(), BDE::list());
|
||||||
|
|
Loading…
Reference in New Issue