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
pull/1/head
Tatsuhiro Tsujikawa 2009-08-18 14:09:56 +00:00
parent 942990354f
commit a4d5134f80
4 changed files with 41 additions and 5 deletions

View File

@ -1,3 +1,18 @@
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
2009-08-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed sqlite3.m4 macro so that sqlite3_open_v2 function is
detected properly.
* m4/sqlite3.m4
2009-08-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Renamed xmlrpc::elements::PARAMS to xmlrpc::elements::A2_PARAMS

View File

@ -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

View File

@ -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

View File

@ -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")