diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-07-02 15:18:13 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-07-02 15:18:13 +0000 |
| commit | 01fdb2aaeb4dcb351931c14ca63d9347f0adc529 (patch) | |
| tree | 94f6e4a327c77b358316d5790224d9cccee8e3c1 /src/InitiateConnectionCommand.cc | |
| parent | 8796993c71c8a326c2f261c01db5066cfc3b2848 (diff) | |
2009-07-03 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Try all available addresses returned by DNS until it gets
connected in HTTP(S)/FTP download
* src/AbstractCommand.cc
* src/AbstractCommand.h
* src/AbstractProxyRequestCommand.cc
* src/AbstractProxyRequestCommand.h
* src/DNSCache.h
* src/DownloadEngine.cc
* src/DownloadEngine.h
* src/FtpInitiateConnectionCommand.cc
* src/FtpInitiateConnectionCommand.h
* src/FtpNegotiationCommand.cc
* src/FtpNegotiationCommand.h
* src/HttpInitiateConnectionCommand.cc
* src/HttpInitiateConnectionCommand.h
* src/HttpRequestCommand.cc
* src/HttpRequestCommand.h
* src/InitiateConnectionCommand.cc
* src/InitiateConnectionCommand.h
* test/DNSCacheTest.cc
* test/Makefile.am
* test/SimpleDNSCacheTest.cc
Diffstat (limited to 'src/InitiateConnectionCommand.cc')
| -rw-r--r-- | src/InitiateConnectionCommand.cc | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/InitiateConnectionCommand.cc b/src/InitiateConnectionCommand.cc index 05c2f9a9..13770f55 100644 --- a/src/InitiateConnectionCommand.cc +++ b/src/InitiateConnectionCommand.cc @@ -46,6 +46,7 @@ #include "RequestGroup.h" #include "DownloadContext.h" #include "Segment.h" +#include "a2functional.h" namespace aria2 { @@ -68,14 +69,17 @@ InitiateConnectionCommand::~InitiateConnectionCommand() {} bool InitiateConnectionCommand::executeInternal() { std::string hostname; + uint16_t port; SharedHandle<Request> proxyRequest = createProxyRequest(); if(proxyRequest.isNull()) { hostname = req->getHost(); + port = req->getPort(); } else { hostname = proxyRequest->getHost(); + port = proxyRequest->getPort(); } std::deque<std::string> addrs; - std::string ipaddr = e->findCachedIPAddress(hostname); + std::string ipaddr = e->findCachedIPAddress(hostname, port); if(ipaddr.empty()) { #ifdef ENABLE_ASYNC_DNS if(getOption()->getAsBool(PREF_ASYNC_DNS)) { @@ -97,14 +101,18 @@ bool InitiateConnectionCommand::executeInternal() { } logger->info(MSG_NAME_RESOLUTION_COMPLETE, cuid, hostname.c_str(), - addrs.front().c_str()); - e->cacheIPAddress(hostname, addrs.front()); + strjoin(addrs.begin(), addrs.end(), ",").c_str()); + for(std::deque<std::string>::const_iterator i = addrs.begin(); + i != addrs.end(); ++i) { + e->cacheIPAddress(hostname, *i, port); + } + ipaddr = e->findCachedIPAddress(hostname, port); } else { logger->info(MSG_DNS_CACHE_HIT, cuid, hostname.c_str(), ipaddr.c_str()); addrs.push_back(ipaddr); } - - Command* command = createNextCommand(addrs, proxyRequest); + Command* command = createNextCommand(hostname, ipaddr, port, + addrs, proxyRequest); e->commands.push_back(command); return true; } |
