mirror of https://github.com/aria2/aria2
2009-02-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Applied AdaptiveURISelector-timeout patch from Pascal Rigaux at Mandriva. I modified the patch: make RequestGroup have the timeout value and AdaptiveURISelector directly modifies that value. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/FtpNegotiationCommand.cc * src/RequestGroup.cc * src/RequestGroup.hpull/1/head
parent
30e183ef54
commit
f16fb1c890
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2009-02-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Applied AdaptiveURISelector-timeout patch from Pascal Rigaux at
|
||||||
|
Mandriva. I modified the patch: make RequestGroup have the
|
||||||
|
timeout value and AdaptiveURISelector directly modifies that
|
||||||
|
value.
|
||||||
|
* src/AbstractCommand.cc
|
||||||
|
* src/AdaptiveURISelector.cc
|
||||||
|
* src/AdaptiveURISelector.h
|
||||||
|
* src/FtpNegotiationCommand.cc
|
||||||
|
* src/RequestGroup.cc
|
||||||
|
* src/RequestGroup.h
|
||||||
|
|
||||||
2009-02-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-02-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Fixed compiler warning
|
Fixed compiler warning
|
||||||
|
|
|
@ -78,7 +78,7 @@ AbstractCommand::AbstractCommand(int32_t cuid,
|
||||||
if(!socket.isNull() && socket->isOpen()) {
|
if(!socket.isNull() && socket->isOpen()) {
|
||||||
setReadCheckSocket(socket);
|
setReadCheckSocket(socket);
|
||||||
}
|
}
|
||||||
timeout = this->e->option->getAsInt(PREF_TIMEOUT);
|
timeout = _requestGroup->getTimeout();
|
||||||
_requestGroup->increaseStreamConnection();
|
_requestGroup->increaseStreamConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,14 @@ AdaptiveURISelector::~AdaptiveURISelector() {}
|
||||||
|
|
||||||
std::string AdaptiveURISelector::select(std::deque<std::string>& uris)
|
std::string AdaptiveURISelector::select(std::deque<std::string>& uris)
|
||||||
{
|
{
|
||||||
|
_logger->debug("AdaptiveURISelector: called %d",
|
||||||
|
_requestGroup->getNumConnection());
|
||||||
|
if (uris.empty() && _requestGroup->getNumConnection() <= 1) {
|
||||||
|
// here we know the download will fail, trying to find previously
|
||||||
|
// failed uris that may succeed with more permissive values
|
||||||
|
mayRetryWithIncreasedTimeout(uris);
|
||||||
|
}
|
||||||
|
|
||||||
std::string selected = selectOne(uris);
|
std::string selected = selectOne(uris);
|
||||||
|
|
||||||
if(selected != A2STR::NIL)
|
if(selected != A2STR::NIL)
|
||||||
|
@ -84,6 +92,27 @@ std::string AdaptiveURISelector::select(std::deque<std::string>& uris)
|
||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdaptiveURISelector::mayRetryWithIncreasedTimeout
|
||||||
|
(std::deque<std::string>& uris)
|
||||||
|
{
|
||||||
|
if (_requestGroup->getTimeout()*2 >= MAX_TIMEOUT) return;
|
||||||
|
_requestGroup->setTimeout(_requestGroup->getTimeout()*2);
|
||||||
|
|
||||||
|
// looking for retries
|
||||||
|
const std::deque<URIResult>& uriResults = _requestGroup->getURIResults();
|
||||||
|
for (std::deque<URIResult>::const_iterator i = uriResults.begin();
|
||||||
|
i != uriResults.end(); ++i) {
|
||||||
|
if ((*i).getResult() == DownloadResult::TIME_OUT) {
|
||||||
|
_logger->debug("AdaptiveURISelector: will retry server with increased"
|
||||||
|
" timeout (%d s): %s",
|
||||||
|
_requestGroup->getTimeout(), (*i).getURI().c_str());
|
||||||
|
uris.push_back((*i).getURI());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::sort(uris.begin(), uris.end());
|
||||||
|
uris.erase(std::unique(uris.begin(), uris.end()), uris.end());
|
||||||
|
}
|
||||||
|
|
||||||
std::string AdaptiveURISelector::selectOne(const std::deque<std::string>& uris)
|
std::string AdaptiveURISelector::selectOne(const std::deque<std::string>& uris)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,12 @@ private:
|
||||||
unsigned int _nbServerToEvaluate;
|
unsigned int _nbServerToEvaluate;
|
||||||
unsigned int _nbConnections;
|
unsigned int _nbConnections;
|
||||||
|
|
||||||
|
static const unsigned int MAX_TIMEOUT = 60;
|
||||||
|
|
||||||
Logger* _logger;
|
Logger* _logger;
|
||||||
|
|
||||||
|
void mayRetryWithIncreasedTimeout(std::deque<std::string>& uris);
|
||||||
|
|
||||||
std::string selectOne(const std::deque<std::string>& uris);
|
std::string selectOne(const std::deque<std::string>& uris);
|
||||||
void adjustLowestSpeedLimit(const std::deque<std::string>& uris,
|
void adjustLowestSpeedLimit(const std::deque<std::string>& uris,
|
||||||
DownloadCommand* command) const;
|
DownloadCommand* command) const;
|
||||||
|
|
|
@ -126,7 +126,7 @@ bool FtpNegotiationCommand::executeInternal() {
|
||||||
|
|
||||||
bool FtpNegotiationCommand::recvGreeting() {
|
bool FtpNegotiationCommand::recvGreeting() {
|
||||||
checkIfConnectionEstablished(socket);
|
checkIfConnectionEstablished(socket);
|
||||||
setTimeout(e->option->getAsInt(PREF_TIMEOUT));
|
setTimeout(_requestGroup->getTimeout());
|
||||||
//socket->setBlockingMode();
|
//socket->setBlockingMode();
|
||||||
disableWriteCheckSocket();
|
disableWriteCheckSocket();
|
||||||
setReadCheckSocket(socket);
|
setReadCheckSocket(socket);
|
||||||
|
|
|
@ -126,6 +126,7 @@ RequestGroup::RequestGroup(const Option* option,
|
||||||
_uriSelector(new InOrderURISelector()),
|
_uriSelector(new InOrderURISelector()),
|
||||||
_lastModifiedTime(Time::null()),
|
_lastModifiedTime(Time::null()),
|
||||||
_fileNotFoundCount(0),
|
_fileNotFoundCount(0),
|
||||||
|
_timeout(option->getAsInt(PREF_TIMEOUT)),
|
||||||
_inMemoryDownload(false),
|
_inMemoryDownload(false),
|
||||||
_option(option),
|
_option(option),
|
||||||
_logger(LogFactory::getInstance())
|
_logger(LogFactory::getInstance())
|
||||||
|
@ -546,7 +547,7 @@ void RequestGroup::createNextCommand(std::deque<Command*>& commands,
|
||||||
const std::string& method)
|
const std::string& method)
|
||||||
{
|
{
|
||||||
std::deque<std::string> pendingURIs;
|
std::deque<std::string> pendingURIs;
|
||||||
for(; !_uris.empty() && numCommand--; ) {
|
for(; numCommand--; ) {
|
||||||
std::string uri = _uriSelector->select(_uris);
|
std::string uri = _uriSelector->select(_uris);
|
||||||
if(uri.empty())
|
if(uri.empty())
|
||||||
continue;
|
continue;
|
||||||
|
@ -1133,4 +1134,14 @@ const std::deque<URIResult>& RequestGroup::getURIResults() const
|
||||||
return _uriResults;
|
return _uriResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RequestGroup::setTimeout(time_t timeout)
|
||||||
|
{
|
||||||
|
_timeout = timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
time_t RequestGroup::getTimeout() const
|
||||||
|
{
|
||||||
|
return _timeout;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -134,6 +134,9 @@ private:
|
||||||
|
|
||||||
unsigned int _fileNotFoundCount;
|
unsigned int _fileNotFoundCount;
|
||||||
|
|
||||||
|
// Timeout used for HTTP/FTP downloads.
|
||||||
|
time_t _timeout;
|
||||||
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
WeakHandle<BtRuntime> _btRuntime;
|
WeakHandle<BtRuntime> _btRuntime;
|
||||||
|
|
||||||
|
@ -424,6 +427,10 @@ public:
|
||||||
bool inMemoryDownload() const;
|
bool inMemoryDownload() const;
|
||||||
|
|
||||||
void tuneDownloadCommand(DownloadCommand* command);
|
void tuneDownloadCommand(DownloadCommand* command);
|
||||||
|
|
||||||
|
void setTimeout(time_t timeout);
|
||||||
|
|
||||||
|
time_t getTimeout() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<RequestGroup> RequestGroupHandle;
|
typedef SharedHandle<RequestGroup> RequestGroupHandle;
|
||||||
|
|
Loading…
Reference in New Issue