2009-02-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Added _maxTries property to RequestGroup and assign the option
	value of PREF_MAX_TRIES to it. AbstractCommand now looks up
	RequestGroup::getMaxTries() instead of
	Option::getAsInt(PREF_MAX_TRIES).
	* src/AbstractCommand.cc
	* src/RequestGroup.cc
	* src/RequestGroup.h
pull/1/head
Tatsuhiro Tsujikawa 2009-02-01 03:03:17 +00:00
parent f16fb1c890
commit 1b26827851
4 changed files with 30 additions and 2 deletions

View File

@ -1,3 +1,13 @@
2009-02-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added _maxTries property to RequestGroup and assign the option
value of PREF_MAX_TRIES to it. AbstractCommand now looks up
RequestGroup::getMaxTries() instead of
Option::getAsInt(PREF_MAX_TRIES).
* src/AbstractCommand.cc
* src/RequestGroup.cc
* src/RequestGroup.h
2009-02-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Applied AdaptiveURISelector-timeout patch from Pascal Rigaux at

View File

@ -165,8 +165,8 @@ bool AbstractCommand::execute() {
logger->info(MSG_RESTARTING_DOWNLOAD, err, cuid, req->getUrl().c_str());
req->addTryCount();
req->resetRedirectCount();
bool isAbort = e->option->getAsInt(PREF_MAX_TRIES) != 0 &&
req->getTryCount() >= (unsigned int)e->option->getAsInt(PREF_MAX_TRIES);
bool isAbort = _requestGroup->getMaxTries() != 0 &&
req->getTryCount() >= _requestGroup->getMaxTries();
if(isAbort) {
onAbort();
}

View File

@ -127,6 +127,7 @@ RequestGroup::RequestGroup(const Option* option,
_lastModifiedTime(Time::null()),
_fileNotFoundCount(0),
_timeout(option->getAsInt(PREF_TIMEOUT)),
_maxTries(option->getAsInt(PREF_MAX_TRIES)),
_inMemoryDownload(false),
_option(option),
_logger(LogFactory::getInstance())
@ -1144,4 +1145,14 @@ time_t RequestGroup::getTimeout() const
return _timeout;
}
void RequestGroup::setMaxTries(unsigned int maxTries)
{
_maxTries = maxTries;
}
unsigned int RequestGroup::getMaxTries() const
{
return _maxTries;
}
} // namespace aria2

View File

@ -137,6 +137,9 @@ private:
// Timeout used for HTTP/FTP downloads.
time_t _timeout;
// How many times HTTP/FTP download should retry.
unsigned int _maxTries;
#ifdef ENABLE_BITTORRENT
WeakHandle<BtRuntime> _btRuntime;
@ -431,6 +434,10 @@ public:
void setTimeout(time_t timeout);
time_t getTimeout() const;
void setMaxTries(unsigned int maxTries);
unsigned int getMaxTries() const;
};
typedef SharedHandle<RequestGroup> RequestGroupHandle;