mirror of https://github.com/aria2/aria2
2010-06-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Made protected member variable private. Added accessor funcs. * src/AutoSaveCommand.cc * src/BtStopDownloadCommand.cc * src/DHTAutoSaveCommand.cc * src/DHTBucketRefreshCommand.cc * src/DHTPeerAnnounceCommand.cc * src/DHTTokenUpdateCommand.cc * src/HaveEraseCommand.cc * src/TimeBasedCommand.h * src/TimedHaltCommand.ccpull/1/head
parent
43460a347f
commit
b357fd39fc
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2010-06-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Made protected member variable private. Added accessor funcs.
|
||||||
|
* src/AutoSaveCommand.cc
|
||||||
|
* src/BtStopDownloadCommand.cc
|
||||||
|
* src/DHTAutoSaveCommand.cc
|
||||||
|
* src/DHTBucketRefreshCommand.cc
|
||||||
|
* src/DHTPeerAnnounceCommand.cc
|
||||||
|
* src/DHTTokenUpdateCommand.cc
|
||||||
|
* src/HaveEraseCommand.cc
|
||||||
|
* src/TimeBasedCommand.h
|
||||||
|
* src/TimedHaltCommand.cc
|
||||||
|
|
||||||
2010-06-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-06-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Made protected member variable private. Added accessor funcs.
|
Made protected member variable private. Added accessor funcs.
|
||||||
|
|
|
@ -49,14 +49,15 @@ AutoSaveCommand::~AutoSaveCommand() {}
|
||||||
|
|
||||||
void AutoSaveCommand::preProcess()
|
void AutoSaveCommand::preProcess()
|
||||||
{
|
{
|
||||||
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
if(getDownloadEngine()->getRequestGroupMan()->downloadFinished() ||
|
||||||
_exit = true;
|
getDownloadEngine()->isHaltRequested()) {
|
||||||
|
enableExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoSaveCommand::process()
|
void AutoSaveCommand::process()
|
||||||
{
|
{
|
||||||
_e->getRequestGroupMan()->save();
|
getDownloadEngine()->getRequestGroupMan()->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -57,14 +57,14 @@ BtStopDownloadCommand::BtStopDownloadCommand
|
||||||
void BtStopDownloadCommand::preProcess()
|
void BtStopDownloadCommand::preProcess()
|
||||||
{
|
{
|
||||||
if(_btRuntime->isHalt() || _pieceStorage->downloadFinished()) {
|
if(_btRuntime->isHalt() || _pieceStorage->downloadFinished()) {
|
||||||
_exit = true;
|
enableExit();
|
||||||
}
|
}
|
||||||
if(_checkPoint.difference(global::wallclock) >= _timeout) {
|
if(_checkPoint.difference(global::wallclock) >= _timeout) {
|
||||||
getLogger()->notice("GID#%s Stop downloading torrent due to"
|
getLogger()->notice("GID#%s Stop downloading torrent due to"
|
||||||
" --bt-stop-timeout option.",
|
" --bt-stop-timeout option.",
|
||||||
util::itos(_requestGroup->getGID()).c_str());
|
util::itos(_requestGroup->getGID()).c_str());
|
||||||
_requestGroup->setHaltRequested(true);
|
_requestGroup->setHaltRequested(true);
|
||||||
_exit = true;
|
enableExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,16 +61,18 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
DHTAutoSaveCommand::DHTAutoSaveCommand(cuid_t cuid, DownloadEngine* e, time_t interval):
|
DHTAutoSaveCommand::DHTAutoSaveCommand
|
||||||
|
(cuid_t cuid, DownloadEngine* e, time_t interval):
|
||||||
TimeBasedCommand(cuid, e, interval) {}
|
TimeBasedCommand(cuid, e, interval) {}
|
||||||
|
|
||||||
DHTAutoSaveCommand::~DHTAutoSaveCommand() {}
|
DHTAutoSaveCommand::~DHTAutoSaveCommand() {}
|
||||||
|
|
||||||
void DHTAutoSaveCommand::preProcess()
|
void DHTAutoSaveCommand::preProcess()
|
||||||
{
|
{
|
||||||
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
if(getDownloadEngine()->getRequestGroupMan()->downloadFinished() ||
|
||||||
|
getDownloadEngine()->isHaltRequested()) {
|
||||||
save();
|
save();
|
||||||
_exit = true;
|
enableExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +83,8 @@ void DHTAutoSaveCommand::process()
|
||||||
|
|
||||||
void DHTAutoSaveCommand::save()
|
void DHTAutoSaveCommand::save()
|
||||||
{
|
{
|
||||||
std::string dhtFile = _e->getOption()->get(PREF_DHT_FILE_PATH);
|
std::string dhtFile =
|
||||||
|
getDownloadEngine()->getOption()->get(PREF_DHT_FILE_PATH);
|
||||||
getLogger()->info("Saving DHT routing table to %s.", dhtFile.c_str());
|
getLogger()->info("Saving DHT routing table to %s.", dhtFile.c_str());
|
||||||
|
|
||||||
std::string tempFile = dhtFile;
|
std::string tempFile = dhtFile;
|
||||||
|
@ -142,7 +145,8 @@ void DHTAutoSaveCommand::setLocalNode(const SharedHandle<DHTNode>& localNode)
|
||||||
_localNode = localNode;
|
_localNode = localNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DHTAutoSaveCommand::setRoutingTable(const SharedHandle<DHTRoutingTable>& routingTable)
|
void DHTAutoSaveCommand::setRoutingTable
|
||||||
|
(const SharedHandle<DHTRoutingTable>& routingTable)
|
||||||
{
|
{
|
||||||
_routingTable = routingTable;
|
_routingTable = routingTable;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,10 @@ DHTBucketRefreshCommand::~DHTBucketRefreshCommand() {}
|
||||||
|
|
||||||
void DHTBucketRefreshCommand::preProcess()
|
void DHTBucketRefreshCommand::preProcess()
|
||||||
{
|
{
|
||||||
_exit = _e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested();
|
if(getDownloadEngine()->getRequestGroupMan()->downloadFinished() ||
|
||||||
|
getDownloadEngine()->isHaltRequested()) {
|
||||||
|
enableExit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DHTBucketRefreshCommand::process()
|
void DHTBucketRefreshCommand::process()
|
||||||
|
@ -62,17 +65,20 @@ void DHTBucketRefreshCommand::process()
|
||||||
_taskQueue->addPeriodicTask1(_taskFactory->createBucketRefreshTask());
|
_taskQueue->addPeriodicTask1(_taskFactory->createBucketRefreshTask());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DHTBucketRefreshCommand::setRoutingTable(const SharedHandle<DHTRoutingTable>& routingTable)
|
void DHTBucketRefreshCommand::setRoutingTable
|
||||||
|
(const SharedHandle<DHTRoutingTable>& routingTable)
|
||||||
{
|
{
|
||||||
_routingTable = routingTable;
|
_routingTable = routingTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DHTBucketRefreshCommand::setTaskQueue(const SharedHandle<DHTTaskQueue>& taskQueue)
|
void DHTBucketRefreshCommand::setTaskQueue
|
||||||
|
(const SharedHandle<DHTTaskQueue>& taskQueue)
|
||||||
{
|
{
|
||||||
_taskQueue = taskQueue;
|
_taskQueue = taskQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DHTBucketRefreshCommand::setTaskFactory(const SharedHandle<DHTTaskFactory>& taskFactory)
|
void DHTBucketRefreshCommand::setTaskFactory
|
||||||
|
(const SharedHandle<DHTTaskFactory>& taskFactory)
|
||||||
{
|
{
|
||||||
_taskFactory = taskFactory;
|
_taskFactory = taskFactory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,10 @@ DHTPeerAnnounceCommand::~DHTPeerAnnounceCommand() {}
|
||||||
|
|
||||||
void DHTPeerAnnounceCommand::preProcess()
|
void DHTPeerAnnounceCommand::preProcess()
|
||||||
{
|
{
|
||||||
_exit = _e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested();
|
if(getDownloadEngine()->getRequestGroupMan()->downloadFinished() ||
|
||||||
|
getDownloadEngine()->isHaltRequested()) {
|
||||||
|
enableExit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DHTPeerAnnounceCommand::process()
|
void DHTPeerAnnounceCommand::process()
|
||||||
|
@ -66,7 +69,8 @@ void DHTPeerAnnounceCommand::process()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DHTPeerAnnounceCommand::setPeerAnnounceStorage(const SharedHandle<DHTPeerAnnounceStorage>& storage)
|
void DHTPeerAnnounceCommand::setPeerAnnounceStorage
|
||||||
|
(const SharedHandle<DHTPeerAnnounceStorage>& storage)
|
||||||
{
|
{
|
||||||
_peerAnnounceStorage = storage;
|
_peerAnnounceStorage = storage;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,10 @@ DHTTokenUpdateCommand::~DHTTokenUpdateCommand() {}
|
||||||
|
|
||||||
void DHTTokenUpdateCommand::preProcess()
|
void DHTTokenUpdateCommand::preProcess()
|
||||||
{
|
{
|
||||||
_exit = _e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested();
|
if(getDownloadEngine()->getRequestGroupMan()->downloadFinished() ||
|
||||||
|
getDownloadEngine()->isHaltRequested()) {
|
||||||
|
enableExit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DHTTokenUpdateCommand::process()
|
void DHTTokenUpdateCommand::process()
|
||||||
|
|
|
@ -51,17 +51,20 @@ HaveEraseCommand::~HaveEraseCommand() {}
|
||||||
|
|
||||||
void HaveEraseCommand::preProcess()
|
void HaveEraseCommand::preProcess()
|
||||||
{
|
{
|
||||||
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
if(getDownloadEngine()->getRequestGroupMan()->downloadFinished() ||
|
||||||
_exit = true;
|
getDownloadEngine()->isHaltRequested()) {
|
||||||
|
enableExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HaveEraseCommand::process()
|
void HaveEraseCommand::process()
|
||||||
{
|
{
|
||||||
size_t numLoop = _e->getRequestGroupMan()->countRequestGroup();
|
size_t numLoop =
|
||||||
|
getDownloadEngine()->getRequestGroupMan()->countRequestGroup();
|
||||||
for(size_t i = 0; i < numLoop; ++i) {
|
for(size_t i = 0; i < numLoop; ++i) {
|
||||||
PieceStorageHandle ps =
|
PieceStorageHandle ps =
|
||||||
_e->getRequestGroupMan()->getRequestGroup(i)->getPieceStorage();
|
getDownloadEngine()->getRequestGroupMan()->getRequestGroup(i)->
|
||||||
|
getPieceStorage();
|
||||||
if(!ps.isNull()) {
|
if(!ps.isNull()) {
|
||||||
ps->removeAdvertisedPiece(5);
|
ps->removeAdvertisedPiece(5);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class DownloadEngine;
|
||||||
|
|
||||||
class TimeBasedCommand : public Command
|
class TimeBasedCommand : public Command
|
||||||
{
|
{
|
||||||
protected:
|
private:
|
||||||
DownloadEngine* _e;
|
DownloadEngine* _e;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,8 +59,23 @@ protected:
|
||||||
time_t _interval; // unit: sec
|
time_t _interval; // unit: sec
|
||||||
|
|
||||||
bool _routineCommand;
|
bool _routineCommand;
|
||||||
private:
|
|
||||||
Timer _checkPoint;
|
Timer _checkPoint;
|
||||||
|
protected:
|
||||||
|
DownloadEngine* getDownloadEngine() const
|
||||||
|
{
|
||||||
|
return _e;
|
||||||
|
}
|
||||||
|
|
||||||
|
void enableExit()
|
||||||
|
{
|
||||||
|
_exit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
time_t getInterval() const
|
||||||
|
{
|
||||||
|
return _interval;
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* preProcess() is called each time when excute() is called.
|
* preProcess() is called each time when excute() is called.
|
||||||
|
|
|
@ -54,22 +54,23 @@ TimedHaltCommand::~TimedHaltCommand() {}
|
||||||
|
|
||||||
void TimedHaltCommand::preProcess()
|
void TimedHaltCommand::preProcess()
|
||||||
{
|
{
|
||||||
if(_e->getRequestGroupMan()->downloadFinished() || _e->isHaltRequested()) {
|
if(getDownloadEngine()->getRequestGroupMan()->downloadFinished() ||
|
||||||
_exit = true;
|
getDownloadEngine()->isHaltRequested()) {
|
||||||
|
enableExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimedHaltCommand::process()
|
void TimedHaltCommand::process()
|
||||||
{
|
{
|
||||||
if(!_e->isHaltRequested()) {
|
if(!getDownloadEngine()->isHaltRequested()) {
|
||||||
getLogger()->notice(MSG_TIME_HAS_PASSED, _interval);
|
getLogger()->notice(MSG_TIME_HAS_PASSED, getInterval());
|
||||||
if(_forceHalt) {
|
if(_forceHalt) {
|
||||||
getLogger()->notice("This is emergency shutdown.");
|
getLogger()->notice("This is emergency shutdown.");
|
||||||
_e->requestForceHalt();
|
getDownloadEngine()->requestForceHalt();
|
||||||
} else {
|
} else {
|
||||||
_e->requestHalt();
|
getDownloadEngine()->requestHalt();
|
||||||
}
|
}
|
||||||
_exit = true;
|
enableExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue