diff --git a/ChangeLog b/ChangeLog index 49ea9716..2b2ac273 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2009-08-18 Tatsuhiro Tsujikawa + + 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 + +2009-08-09 Tatsuhiro Tsujikawa + + Fixed sqlite3.m4 macro so that sqlite3_open_v2 function is + detected properly. + * m4/sqlite3.m4 + 2009-08-09 Tatsuhiro Tsujikawa Renamed xmlrpc::elements::PARAMS to xmlrpc::elements::A2_PARAMS diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index 28c0e1f7..afb96224 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -546,10 +546,10 @@ bool AbstractCommand::checkIfConnectionEstablished if(socket->isReadable(0)) { std::string error = socket->getSocketError(); if(!error.empty()) { + // See also InitiateConnectionCommand::executeInternal() e->markBadIPAddress(connectedHostname, connectedAddr, connectedPort); if(!e->findCachedIPAddress(connectedHostname, connectedPort).empty()) { - logger->info("CUID#%d - Could not to connect to %s:%u." - " Trying another address", + logger->info(MSG_CONNECT_FAILED_AND_RETRY, cuid, connectedAddr.c_str(), connectedPort); Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand 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 diff --git a/src/message.h b/src/message.h index 227e70f1..3fa14541 100644 --- a/src/message.h +++ b/src/message.h @@ -89,6 +89,8 @@ #define MSG_TRACKER_REQUEST_CREATION_FAILED _("CUID#%d - Cannot create tracker request.") #define MSG_CREATING_TRACKER_REQUEST _("CUID#%d - Creating new tracker request command #%d") #define MSG_DHT_ENABLED_PEER _("CUID#%d - The peer is DHT-enabled.") +#define MSG_CONNECT_FAILED_AND_RETRY "CUID#%d - Could not to connect to %s:%u."\ + " Trying another address" #define MSG_UNRECOGNIZED_URI _("Unrecognized URI or unsupported protocol: %s") #define MSG_TRACKER_WARNING_MESSAGE _("Tracker returned warning message: %s")