summaryrefslogtreecommitdiff
path: root/src/InitiateConnectionCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-06-23 21:55:52 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-06-23 21:55:52 +0900
commitfa9f3fb5a3c8912a0a6880ffba9c72f4424ea044 (patch)
treedeb0b47b085a3a689bf386409734bfd3f72f57d2 /src/InitiateConnectionCommand.cc
parentbb5b7eeedb3ce7396007818cbab4f5f5660997a5 (diff)
Wrap Command object in std::unique_ptr
Diffstat (limited to 'src/InitiateConnectionCommand.cc')
-rw-r--r--src/InitiateConnectionCommand.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/InitiateConnectionCommand.cc b/src/InitiateConnectionCommand.cc
index 069a5a8f..1d49d7fb 100644
--- a/src/InitiateConnectionCommand.cc
+++ b/src/InitiateConnectionCommand.cc
@@ -87,13 +87,12 @@ bool InitiateConnectionCommand::executeInternal() {
std::vector<std::string> addrs;
std::string ipaddr = resolveHostname(addrs, hostname, port);
if(ipaddr.empty()) {
- getDownloadEngine()->addCommand(this);
+ addCommandSelf();
return false;
}
try {
- Command* command = createNextCommand(hostname, ipaddr, port,
- addrs, proxyRequest);
- getDownloadEngine()->addCommand(command);
+ getDownloadEngine()->addCommand(createNextCommand(hostname, ipaddr, port,
+ addrs, proxyRequest));
return true;
} catch(RecoverableException& ex) {
// Catch exception and retry another address.
@@ -106,12 +105,12 @@ bool InitiateConnectionCommand::executeInternal() {
A2_LOG_INFO(fmt(MSG_CONNECT_FAILED_AND_RETRY,
getCuid(),
ipaddr.c_str(), port));
- Command* command =
+ auto command =
InitiateConnectionCommandFactory::createInitiateConnectionCommand
(getCuid(), getRequest(), getFileEntry(), getRequestGroup(),
getDownloadEngine());
getDownloadEngine()->setNoWait(true);
- getDownloadEngine()->addCommand(command);
+ getDownloadEngine()->addCommand(std::move(command));
return true;
}
getDownloadEngine()->removeCachedIPAddress(hostname, port);
@@ -149,12 +148,12 @@ InitiateConnectionCommand::createBackupIPv4ConnectCommand
eoi = addrs.end(); i != eoi; ++i) {
if(inetPton(AF_INET, (*i).c_str(), &buf) == 0) {
info.reset(new BackupConnectInfo());
- BackupIPv4ConnectCommand* command = new BackupIPv4ConnectCommand
+ auto command = make_unique<BackupIPv4ConnectCommand>
(getDownloadEngine()->newCUID(), *i, port, info, mainCommand,
getRequestGroup(), getDownloadEngine());
A2_LOG_INFO(fmt("Issue backup connection command CUID#%" PRId64
", addr=%s", command->getCuid(), (*i).c_str()));
- getDownloadEngine()->addCommand(command);
+ getDownloadEngine()->addCommand(std::move(command));
return info;
}
}