mirror of https://github.com/aria2/aria2
Use std::string for SocketPoolEntry::options_
Currently, we only store 1 value for FTP download. std::map is overkill in the this situation.pull/28/head
parent
c13dc166de
commit
a20e279606
|
@ -328,7 +328,7 @@ void DownloadEngine::poolSocket
|
||||||
const std::string& proxyhost,
|
const std::string& proxyhost,
|
||||||
uint16_t proxyport,
|
uint16_t proxyport,
|
||||||
const SharedHandle<SocketCore>& sock,
|
const SharedHandle<SocketCore>& sock,
|
||||||
const std::map<std::string, std::string>& options,
|
const std::string& options,
|
||||||
time_t timeout)
|
time_t timeout)
|
||||||
{
|
{
|
||||||
SocketPoolEntry e(sock, options, timeout);
|
SocketPoolEntry e(sock, options, timeout);
|
||||||
|
@ -387,7 +387,7 @@ void DownloadEngine::poolSocket
|
||||||
const std::string& username,
|
const std::string& username,
|
||||||
const SharedHandle<Request>& proxyRequest,
|
const SharedHandle<Request>& proxyRequest,
|
||||||
const SharedHandle<SocketCore>& socket,
|
const SharedHandle<SocketCore>& socket,
|
||||||
const std::map<std::string, std::string>& options,
|
const std::string& options,
|
||||||
time_t timeout)
|
time_t timeout)
|
||||||
{
|
{
|
||||||
if(!proxyRequest) {
|
if(!proxyRequest) {
|
||||||
|
@ -441,7 +441,7 @@ DownloadEngine::popPooledSocket
|
||||||
|
|
||||||
SharedHandle<SocketCore>
|
SharedHandle<SocketCore>
|
||||||
DownloadEngine::popPooledSocket
|
DownloadEngine::popPooledSocket
|
||||||
(std::map<std::string, std::string>& options,
|
(std::string& options,
|
||||||
const std::string& ipaddr, uint16_t port,
|
const std::string& ipaddr, uint16_t port,
|
||||||
const std::string& username,
|
const std::string& username,
|
||||||
const std::string& proxyhost, uint16_t proxyport)
|
const std::string& proxyhost, uint16_t proxyport)
|
||||||
|
@ -475,7 +475,7 @@ DownloadEngine::popPooledSocket
|
||||||
|
|
||||||
SharedHandle<SocketCore>
|
SharedHandle<SocketCore>
|
||||||
DownloadEngine::popPooledSocket
|
DownloadEngine::popPooledSocket
|
||||||
(std::map<std::string, std::string>& options,
|
(std::string& options,
|
||||||
const std::vector<std::string>& ipaddrs, uint16_t port,
|
const std::vector<std::string>& ipaddrs, uint16_t port,
|
||||||
const std::string& username)
|
const std::string& username)
|
||||||
{
|
{
|
||||||
|
@ -492,16 +492,18 @@ DownloadEngine::popPooledSocket
|
||||||
|
|
||||||
DownloadEngine::SocketPoolEntry::SocketPoolEntry
|
DownloadEngine::SocketPoolEntry::SocketPoolEntry
|
||||||
(const SharedHandle<SocketCore>& socket,
|
(const SharedHandle<SocketCore>& socket,
|
||||||
const std::map<std::string, std::string>& options,
|
const std::string& options,
|
||||||
time_t timeout):
|
time_t timeout)
|
||||||
socket_(socket),
|
: socket_(socket),
|
||||||
options_(options),
|
options_(options),
|
||||||
timeout_(timeout) {}
|
timeout_(timeout)
|
||||||
|
{}
|
||||||
|
|
||||||
DownloadEngine::SocketPoolEntry::SocketPoolEntry
|
DownloadEngine::SocketPoolEntry::SocketPoolEntry
|
||||||
(const SharedHandle<SocketCore>& socket, time_t timeout):
|
(const SharedHandle<SocketCore>& socket, time_t timeout)
|
||||||
socket_(socket),
|
: socket_(socket),
|
||||||
timeout_(timeout) {}
|
timeout_(timeout)
|
||||||
|
{}
|
||||||
|
|
||||||
DownloadEngine::SocketPoolEntry::~SocketPoolEntry() {}
|
DownloadEngine::SocketPoolEntry::~SocketPoolEntry() {}
|
||||||
|
|
||||||
|
|
|
@ -84,15 +84,15 @@ private:
|
||||||
class SocketPoolEntry {
|
class SocketPoolEntry {
|
||||||
private:
|
private:
|
||||||
SharedHandle<SocketCore> socket_;
|
SharedHandle<SocketCore> socket_;
|
||||||
|
// protocol specific option string
|
||||||
std::map<std::string, std::string> options_;
|
std::string options_;
|
||||||
|
|
||||||
time_t timeout_;
|
time_t timeout_;
|
||||||
|
|
||||||
Timer registeredTime_;
|
Timer registeredTime_;
|
||||||
public:
|
public:
|
||||||
SocketPoolEntry(const SharedHandle<SocketCore>& socket,
|
SocketPoolEntry(const SharedHandle<SocketCore>& socket,
|
||||||
const std::map<std::string, std::string>& option,
|
const std::string& option,
|
||||||
time_t timeout);
|
time_t timeout);
|
||||||
|
|
||||||
SocketPoolEntry(const SharedHandle<SocketCore>& socket,
|
SocketPoolEntry(const SharedHandle<SocketCore>& socket,
|
||||||
|
@ -107,7 +107,7 @@ private:
|
||||||
return socket_;
|
return socket_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::map<std::string, std::string>& getOptions() const
|
const std::string& getOptions() const
|
||||||
{
|
{
|
||||||
return options_;
|
return options_;
|
||||||
}
|
}
|
||||||
|
@ -242,14 +242,14 @@ public:
|
||||||
const std::string& username,
|
const std::string& username,
|
||||||
const std::string& proxyhost, uint16_t proxyport,
|
const std::string& proxyhost, uint16_t proxyport,
|
||||||
const SharedHandle<SocketCore>& sock,
|
const SharedHandle<SocketCore>& sock,
|
||||||
const std::map<std::string, std::string>& options,
|
const std::string& options,
|
||||||
time_t timeout = 15);
|
time_t timeout = 15);
|
||||||
|
|
||||||
void poolSocket(const SharedHandle<Request>& request,
|
void poolSocket(const SharedHandle<Request>& request,
|
||||||
const std::string& username,
|
const std::string& username,
|
||||||
const SharedHandle<Request>& proxyRequest,
|
const SharedHandle<Request>& proxyRequest,
|
||||||
const SharedHandle<SocketCore>& socket,
|
const SharedHandle<SocketCore>& socket,
|
||||||
const std::map<std::string, std::string>& options,
|
const std::string& options,
|
||||||
time_t timeout = 15);
|
time_t timeout = 15);
|
||||||
|
|
||||||
void poolSocket(const std::string& ipaddr, uint16_t port,
|
void poolSocket(const std::string& ipaddr, uint16_t port,
|
||||||
|
@ -268,7 +268,7 @@ public:
|
||||||
const std::string& proxyhost, uint16_t proxyport);
|
const std::string& proxyhost, uint16_t proxyport);
|
||||||
|
|
||||||
SharedHandle<SocketCore> popPooledSocket
|
SharedHandle<SocketCore> popPooledSocket
|
||||||
(std::map<std::string, std::string>& options,
|
(std::string& options,
|
||||||
const std::string& ipaddr,
|
const std::string& ipaddr,
|
||||||
uint16_t port,
|
uint16_t port,
|
||||||
const std::string& username,
|
const std::string& username,
|
||||||
|
@ -280,7 +280,7 @@ public:
|
||||||
|
|
||||||
SharedHandle<SocketCore>
|
SharedHandle<SocketCore>
|
||||||
popPooledSocket
|
popPooledSocket
|
||||||
(std::map<std::string, std::string>& options,
|
(std::string& options,
|
||||||
const std::vector<std::string>& ipaddrs,
|
const std::vector<std::string>& ipaddrs,
|
||||||
uint16_t port,
|
uint16_t port,
|
||||||
const std::string& username);
|
const std::string& username);
|
||||||
|
|
|
@ -85,11 +85,9 @@ bool FtpFinishDownloadCommand::execute()
|
||||||
}
|
}
|
||||||
if(status == 226) {
|
if(status == 226) {
|
||||||
if(getOption()->getAsBool(PREF_FTP_REUSE_CONNECTION)) {
|
if(getOption()->getAsBool(PREF_FTP_REUSE_CONNECTION)) {
|
||||||
std::map<std::string, std::string> options;
|
|
||||||
options["baseWorkingDir"] = ftpConnection_->getBaseWorkingDir();
|
|
||||||
getDownloadEngine()->poolSocket
|
getDownloadEngine()->poolSocket
|
||||||
(getRequest(), ftpConnection_->getUser(), createProxyRequest(),
|
(getRequest(), ftpConnection_->getUser(), createProxyRequest(),
|
||||||
getSocket(), options);
|
getSocket(), ftpConnection_->getBaseWorkingDir());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
A2_LOG_INFO(fmt("CUID#%" PRId64 " - Bad status for transfer complete.",
|
A2_LOG_INFO(fmt("CUID#%" PRId64 " - Bad status for transfer complete.",
|
||||||
|
|
|
@ -76,7 +76,7 @@ Command* FtpInitiateConnectionCommand::createNextCommand
|
||||||
{
|
{
|
||||||
Command* command;
|
Command* command;
|
||||||
if(proxyRequest) {
|
if(proxyRequest) {
|
||||||
std::map<std::string, std::string> options;
|
std::string options;
|
||||||
SharedHandle<SocketCore> pooledSocket;
|
SharedHandle<SocketCore> pooledSocket;
|
||||||
std::string proxyMethod = resolveProxyMethod(getRequest()->getProtocol());
|
std::string proxyMethod = resolveProxyMethod(getRequest()->getProtocol());
|
||||||
if(proxyMethod == V_GET) {
|
if(proxyMethod == V_GET) {
|
||||||
|
@ -124,12 +124,13 @@ Command* FtpInitiateConnectionCommand::createNextCommand
|
||||||
} else {
|
} else {
|
||||||
setConnectedAddrInfo(getRequest(), hostname, pooledSocket);
|
setConnectedAddrInfo(getRequest(), hostname, pooledSocket);
|
||||||
if(proxyMethod == V_TUNNEL) {
|
if(proxyMethod == V_TUNNEL) {
|
||||||
|
// options contains "baseWorkingDir"
|
||||||
command =
|
command =
|
||||||
new FtpNegotiationCommand(getCuid(), getRequest(), getFileEntry(),
|
new FtpNegotiationCommand(getCuid(), getRequest(), getFileEntry(),
|
||||||
getRequestGroup(), getDownloadEngine(),
|
getRequestGroup(), getDownloadEngine(),
|
||||||
pooledSocket,
|
pooledSocket,
|
||||||
FtpNegotiationCommand::SEQ_SEND_CWD_PREP,
|
FtpNegotiationCommand::SEQ_SEND_CWD_PREP,
|
||||||
options["baseWorkingDir"]);
|
options);
|
||||||
} else if(proxyMethod == V_GET) {
|
} else if(proxyMethod == V_GET) {
|
||||||
// Use GET for FTP via HTTP proxy.
|
// Use GET for FTP via HTTP proxy.
|
||||||
getRequest()->setMethod(Request::METHOD_GET);
|
getRequest()->setMethod(Request::METHOD_GET);
|
||||||
|
@ -150,7 +151,7 @@ Command* FtpInitiateConnectionCommand::createNextCommand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::map<std::string, std::string> options;
|
std::string options;
|
||||||
SharedHandle<SocketCore> pooledSocket =
|
SharedHandle<SocketCore> pooledSocket =
|
||||||
getDownloadEngine()->popPooledSocket
|
getDownloadEngine()->popPooledSocket
|
||||||
(options, resolvedAddresses,
|
(options, resolvedAddresses,
|
||||||
|
@ -169,12 +170,13 @@ Command* FtpInitiateConnectionCommand::createNextCommand
|
||||||
getRequest()->setConnectedAddrInfo(hostname, addr, port);
|
getRequest()->setConnectedAddrInfo(hostname, addr, port);
|
||||||
command = c;
|
command = c;
|
||||||
} else {
|
} else {
|
||||||
|
// options contains "baseWorkingDir"
|
||||||
command =
|
command =
|
||||||
new FtpNegotiationCommand(getCuid(), getRequest(), getFileEntry(),
|
new FtpNegotiationCommand(getCuid(), getRequest(), getFileEntry(),
|
||||||
getRequestGroup(), getDownloadEngine(),
|
getRequestGroup(), getDownloadEngine(),
|
||||||
pooledSocket,
|
pooledSocket,
|
||||||
FtpNegotiationCommand::SEQ_SEND_CWD_PREP,
|
FtpNegotiationCommand::SEQ_SEND_CWD_PREP,
|
||||||
options["baseWorkingDir"]);
|
options);
|
||||||
setConnectedAddrInfo(getRequest(), hostname, pooledSocket);
|
setConnectedAddrInfo(getRequest(), hostname, pooledSocket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -959,10 +959,10 @@ bool FtpNegotiationCommand::processSequence
|
||||||
void FtpNegotiationCommand::poolConnection() const
|
void FtpNegotiationCommand::poolConnection() const
|
||||||
{
|
{
|
||||||
if(getOption()->getAsBool(PREF_FTP_REUSE_CONNECTION)) {
|
if(getOption()->getAsBool(PREF_FTP_REUSE_CONNECTION)) {
|
||||||
std::map<std::string, std::string> options;
|
// Store ftp_->getBaseWorkingDir() as options
|
||||||
options["baseWorkingDir"] = ftp_->getBaseWorkingDir();
|
|
||||||
getDownloadEngine()->poolSocket(getRequest(), ftp_->getUser(),
|
getDownloadEngine()->poolSocket(getRequest(), ftp_->getUser(),
|
||||||
createProxyRequest(), getSocket(), options);
|
createProxyRequest(), getSocket(),
|
||||||
|
ftp_->getBaseWorkingDir());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue