diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-08-18 14:09:56 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-08-18 14:09:56 +0000 |
| commit | a4d5134f803eb6548752ffb44c482d77e55822e7 (patch) | |
| tree | 6553c8d2b6b35b236e71a3e320af3134de61dca3 /src/InitiateConnectionCommand.cc | |
| parent | 942990354f671a7235b8325f69730d3e4a153119 (diff) | |
2009-08-18 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that download fails if
SocketCore::establishConnection() throws exception and aria2
doesn't try another address.
* src/AbstractCommand.cc
* src/InitiateConnectionCommand.cc
* src/message.h
Diffstat (limited to 'src/InitiateConnectionCommand.cc')
| -rw-r--r-- | src/InitiateConnectionCommand.cc | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/InitiateConnectionCommand.cc b/src/InitiateConnectionCommand.cc index 13770f55..f0b34838 100644 --- a/src/InitiateConnectionCommand.cc +++ b/src/InitiateConnectionCommand.cc @@ -47,6 +47,7 @@ #include "DownloadContext.h" #include "Segment.h" #include "a2functional.h" +#include "InitiateConnectionCommandFactory.h" namespace aria2 { @@ -111,10 +112,28 @@ bool InitiateConnectionCommand::executeInternal() { logger->info(MSG_DNS_CACHE_HIT, cuid, hostname.c_str(), ipaddr.c_str()); addrs.push_back(ipaddr); } - Command* command = createNextCommand(hostname, ipaddr, port, + try { + Command* command = createNextCommand(hostname, ipaddr, port, addrs, proxyRequest); - e->commands.push_back(command); - return true; + e->commands.push_back(command); + return true; + } catch(RecoverableException& ex) { + // Catch exception and retry another address. + // See also AbstractCommand::checkIfConnectionEstablished + e->markBadIPAddress(hostname, ipaddr, port); + if(!e->findCachedIPAddress(hostname, port).empty()) { + logger->info(EX_EXCEPTION_CAUGHT, ex); + logger->info(MSG_CONNECT_FAILED_AND_RETRY, cuid, ipaddr.c_str(), port); + Command* command = + InitiateConnectionCommandFactory::createInitiateConnectionCommand + (cuid, req, _fileEntry, _requestGroup, e); + e->setNoWait(true); + e->commands.push_back(command); + return true; + } + e->removeCachedIPAddress(hostname, port); + throw; + } } } // namespace aria2 |
