mirror of https://github.com/aria2/aria2
2007-11-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Now SleepCommand dispatches nextCommand when halt is requested. It avoids a possible long wait after hitting CTRL-C. * src/SleepCommand.{h, cc} * src/RequestGroupAware.{h, cc}pull/1/head
parent
d8ae699182
commit
bcbadb3b6b
|
@ -1,3 +1,10 @@
|
|||
2007-11-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Now SleepCommand dispatches nextCommand when halt is requested.
|
||||
It avoids a possible long wait after hitting CTRL-C.
|
||||
* src/SleepCommand.{h, cc}
|
||||
* src/RequestGroupAware.{h, cc}
|
||||
|
||||
2007-11-04 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Fixed: the listen port sent to the tracker is wrong. If aria2 fails
|
||||
|
|
|
@ -45,3 +45,8 @@ RequestGroupAware::~RequestGroupAware()
|
|||
{
|
||||
_requestGroup->decreaseNumCommand();
|
||||
}
|
||||
|
||||
RequestGroup* RequestGroupAware::getRequestGroup() const
|
||||
{
|
||||
return _requestGroup;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ public:
|
|||
RequestGroupAware(RequestGroup* requestGroup);
|
||||
|
||||
~RequestGroupAware();
|
||||
|
||||
RequestGroup* getRequestGroup() const;
|
||||
};
|
||||
|
||||
#endif // _D_REQUEST_GROUP_AWARE_H_
|
||||
|
|
|
@ -34,20 +34,22 @@
|
|||
/* copyright --> */
|
||||
#include "SleepCommand.h"
|
||||
#include "Util.h"
|
||||
#include "RequestGroupAware.h"
|
||||
#include "RequestGroup.h"
|
||||
|
||||
SleepCommand::SleepCommand(int32_t cuid, DownloadEngine* e, Command* nextCommand, int32_t wait):
|
||||
Command(cuid), engine(e), nextCommand(nextCommand), wait(wait) {}
|
||||
|
||||
SleepCommand::~SleepCommand() {
|
||||
if(nextCommand != NULL) {
|
||||
if(nextCommand) {
|
||||
delete(nextCommand);
|
||||
}
|
||||
}
|
||||
|
||||
bool SleepCommand::execute() {
|
||||
if(checkPoint.elapsed(wait)) {
|
||||
if(checkPoint.elapsed(wait) || isHaltRequested()) {
|
||||
engine->commands.push_back(nextCommand);
|
||||
nextCommand = NULL;
|
||||
nextCommand = 0;
|
||||
return true;
|
||||
} else {
|
||||
engine->commands.push_back(this);
|
||||
|
@ -55,3 +57,16 @@ bool SleepCommand::execute() {
|
|||
}
|
||||
}
|
||||
|
||||
bool SleepCommand::isHaltRequested() const
|
||||
{
|
||||
if(engine->isHaltRequested()) {
|
||||
return true;
|
||||
}
|
||||
RequestGroupAware* requestGroupAware = dynamic_cast<RequestGroupAware*>(nextCommand);
|
||||
if(requestGroupAware) {
|
||||
if(requestGroupAware->getRequestGroup()->isHaltRequested()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@ private:
|
|||
Command* nextCommand;
|
||||
int32_t wait;
|
||||
Time checkPoint;
|
||||
|
||||
bool isHaltRequested() const;
|
||||
|
||||
public:
|
||||
SleepCommand(int32_t cuid, DownloadEngine* e, Command* nextCommand, int32_t wait);
|
||||
virtual ~SleepCommand();
|
||||
|
|
Loading…
Reference in New Issue