Skip to content

Commit

Permalink
Add CreateRequestCommand with STATUS_INACTIVE instead of SleepCommand
Browse files Browse the repository at this point in the history
+ DownloadFailureException.

Throwing DownloadFailureException may stop download unexpectedly when
--reuse-uri is false. Using CreateRequestCommand with STATUS_INACTIVE,
they can be executed next iteration with
DownloadEngine::setRefreshInterval(0).
  • Loading branch information
tatsuhiro-t committed May 16, 2011
1 parent c9fe4c6 commit 653f04e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/AbstractCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ bool AbstractCommand::execute() {
// no URIs available, so don't retry.
if(getSegmentMan()->allSegmentsIgnored()) {
A2_LOG_DEBUG("All segments are ignored.");
// In this case, the error might be already set in
// RequestGroup, so use it here.
throw DOWNLOAD_FAILURE_EXCEPTION2
("No URI available.", requestGroup_->getLastErrorCode());
// This will execute other idle Commands and let them
// finish quickly.
e_->setRefreshInterval(0);
return true;
} else {
return prepareForRetry(1);
}
Expand Down Expand Up @@ -383,9 +383,10 @@ bool AbstractCommand::prepareForRetry(time_t wait) {
e_->setNoWait(true);
e_->addCommand(command);
} else {
SleepCommand* scom = new SleepCommand(getCuid(), e_, requestGroup_,
command, wait);
e_->addCommand(scom);
// We don't use wait so that Command can be executed by
// DownloadEngine::setRefreshInterval(0).
command->setStatus(Command::STATUS_INACTIVE);
e_->addCommand(command);
}
return true;
}
Expand Down

0 comments on commit 653f04e

Please sign in to comment.