浏览代码

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
Tatsuhiro Tsujikawa 16 年之前
父节点
当前提交
a4d5134f80
共有 4 个文件被更改,包括 41 次插入5 次删除
  1. 15 0
      ChangeLog
  2. 2 2
      src/AbstractCommand.cc
  3. 22 3
      src/InitiateConnectionCommand.cc
  4. 2 0
      src/message.h

+ 15 - 0
ChangeLog

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

+ 2 - 2
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

+ 22 - 3
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

+ 2 - 0
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")