mirror of https://github.com/aria2/aria2
Use std::unique_ptr for AsyncResolverMan
parent
74d6d64271
commit
0d85fb0df3
|
@ -91,7 +91,7 @@ AbstractCommand::AbstractCommand
|
|||
req_(req), fileEntry_(fileEntry), e_(e), socket_(s),
|
||||
socketRecvBuffer_(socketRecvBuffer),
|
||||
#ifdef ENABLE_ASYNC_DNS
|
||||
asyncNameResolverMan_(new AsyncNameResolverMan()),
|
||||
asyncNameResolverMan_(make_unique<AsyncNameResolverMan>()),
|
||||
#endif // ENABLE_ASYNC_DNS
|
||||
checkSocketIsReadable_(false), checkSocketIsWritable_(false),
|
||||
incNumConnection_(incNumConnection),
|
||||
|
|
|
@ -76,7 +76,7 @@ private:
|
|||
std::vector<std::shared_ptr<Segment> > segments_;
|
||||
|
||||
#ifdef ENABLE_ASYNC_DNS
|
||||
std::shared_ptr<AsyncNameResolverMan> asyncNameResolverMan_;
|
||||
std::unique_ptr<AsyncNameResolverMan> asyncNameResolverMan_;
|
||||
#endif // ENABLE_ASYNC_DNS
|
||||
|
||||
bool checkSocketIsReadable_;
|
||||
|
|
|
@ -94,13 +94,13 @@ void AsyncNameResolverMan::startAsyncFamily(const std::string& hostname,
|
|||
DownloadEngine* e,
|
||||
Command* command)
|
||||
{
|
||||
asyncNameResolver_[numResolver_].reset
|
||||
(new AsyncNameResolver(family
|
||||
asyncNameResolver_[numResolver_] = std::make_shared<AsyncNameResolver>
|
||||
(family
|
||||
#ifdef HAVE_ARES_ADDR_NODE
|
||||
,
|
||||
e->getAsyncDNSServers()
|
||||
,
|
||||
e->getAsyncDNSServers()
|
||||
#endif // HAVE_ARES_ADDR_NODE
|
||||
));
|
||||
);
|
||||
asyncNameResolver_[numResolver_]->resolve(hostname);
|
||||
setNameResolverCheck(numResolver_, e, command);
|
||||
}
|
||||
|
@ -111,9 +111,8 @@ const
|
|||
for(size_t i = 0; i < numResolver_; ++i) {
|
||||
if(asyncNameResolver_[i]->getStatus() ==
|
||||
AsyncNameResolver::STATUS_SUCCESS) {
|
||||
const std::vector<std::string>& addrs =
|
||||
asyncNameResolver_[i]->getResolvedAddresses();
|
||||
res.insert(res.end(), addrs.begin(), addrs.end());
|
||||
auto& addrs = asyncNameResolver_[i]->getResolvedAddresses();
|
||||
res.insert(std::end(res), std::begin(addrs), std::end(addrs));
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -59,7 +59,7 @@ private:
|
|||
DownloadEngine* e_;
|
||||
|
||||
#ifdef ENABLE_ASYNC_DNS
|
||||
std::shared_ptr<AsyncNameResolverMan> asyncNameResolverMan_;
|
||||
std::unique_ptr<AsyncNameResolverMan> asyncNameResolverMan_;
|
||||
#endif // ENABLE_ASYNC_DNS
|
||||
|
||||
DHTTaskQueue* taskQueue_;
|
||||
|
|
|
@ -58,7 +58,7 @@ NameResolveCommand::NameResolveCommand
|
|||
: Command(cuid),
|
||||
e_(e),
|
||||
#ifdef ENABLE_ASYNC_DNS
|
||||
asyncNameResolverMan_(new AsyncNameResolverMan()),
|
||||
asyncNameResolverMan_(make_unique<AsyncNameResolverMan>()),
|
||||
#endif // ENABLE_ASYNC_DNS
|
||||
req_(req)
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ private:
|
|||
DownloadEngine* e_;
|
||||
|
||||
#ifdef ENABLE_ASYNC_DNS
|
||||
std::shared_ptr<AsyncNameResolverMan> asyncNameResolverMan_;
|
||||
std::unique_ptr<AsyncNameResolverMan> asyncNameResolverMan_;
|
||||
#endif // ENABLE_ASYNC_DNS
|
||||
|
||||
#ifdef ENABLE_ASYNC_DNS
|
||||
|
|
Loading…
Reference in New Issue