From 990756ca38afc785d3aed4306709969e3eb643d9 Mon Sep 17 00:00:00 2001 From: Alden Torres Date: Thu, 30 Mar 2017 23:00:59 -0400 Subject: [PATCH] code cleanup related to async_resolve (#1873) --- include/libtorrent/aux_/session_impl.hpp | 2 -- include/libtorrent/aux_/session_interface.hpp | 7 ------ src/session_impl.cpp | 10 +------- src/torrent.cpp | 23 ++++++++----------- 4 files changed, 11 insertions(+), 31 deletions(-) diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 52a5760c7..9e1f40a23 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -287,8 +287,6 @@ namespace libtorrent io_service& get_io_service() override { return m_io_service; } resolver_interface& get_resolver() override { return m_host_resolver; } - void async_resolve(std::string const& host, int flags - , callback_t const& h) override; aux::vector& torrent_list(int i) override { diff --git a/include/libtorrent/aux_/session_interface.hpp b/include/libtorrent/aux_/session_interface.hpp index 63145a26c..73d88cdd9 100644 --- a/include/libtorrent/aux_/session_interface.hpp +++ b/include/libtorrent/aux_/session_interface.hpp @@ -148,13 +148,6 @@ namespace libtorrent { namespace aux virtual io_service& get_io_service() = 0; virtual resolver_interface& get_resolver() = 0; - typedef std::function const&)> - callback_t; - - // TODO: 2 remove this. There's already get_resolver() - virtual void async_resolve(std::string const& host, int flags - , callback_t const& h) = 0; - virtual bool has_connection(peer_connection* p) const = 0; virtual void insert_peer(std::shared_ptr const& c) = 0; diff --git a/src/session_impl.cpp b/src/session_impl.cpp index b3ca05d80..1ca8f4267 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -45,9 +45,7 @@ POSSIBILITY OF SUCH DAMAGE. #endif #include "libtorrent/aux_/disable_warnings_push.hpp" - #include - #include "libtorrent/aux_/disable_warnings_pop.hpp" #include "libtorrent/aux_/openssl.hpp" @@ -671,13 +669,7 @@ namespace aux { #endif } - void session_impl::async_resolve(std::string const& host, int flags - , session_interface::callback_t const& h) - { - m_host_resolver.async_resolve(host, flags, h); - } - - void session_impl::save_state(entry* eptr, std::uint32_t flags) const + void session_impl::save_state(entry* eptr, std::uint32_t const flags) const { TORRENT_ASSERT(is_single_thread()); diff --git a/src/torrent.cpp b/src/torrent.cpp index 7c05ba184..7580b4f10 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -44,15 +44,13 @@ POSSIBILITY OF SUCH DAMAGE. #include // for snprintf #include -#include "libtorrent/aux_/disable_warnings_push.hpp" - #ifdef TORRENT_USE_OPENSSL #include "libtorrent/ssl_stream.hpp" +#include "libtorrent/aux_/disable_warnings_push.hpp" #include #include -#endif // TORRENT_USE_OPENSSL - #include "libtorrent/aux_/disable_warnings_pop.hpp" +#endif // TORRENT_USE_OPENSSL #include "libtorrent/torrent.hpp" #include "libtorrent/torrent_handle.hpp" @@ -3051,9 +3049,8 @@ namespace libtorrent #endif { ADD_OUTSTANDING_ASYNC("torrent::on_peer_name_lookup"); - m_ses.async_resolve(i.hostname, resolver_interface::abort_on_shutdown - , std::bind(&torrent::on_peer_name_lookup - , shared_from_this(), _1, _2, i.port)); + m_ses.get_resolver().async_resolve(i.hostname, resolver_interface::abort_on_shutdown + , std::bind(&torrent::on_peer_name_lookup, shared_from_this(), _1, _2, i.port)); } } @@ -5546,8 +5543,8 @@ namespace libtorrent // use proxy web->resolving = true; - m_ses.async_resolve(ps.hostname, resolver_interface::abort_on_shutdown - , [self,web,proxy_port](error_code const& e, std::vector
const& addrs) + m_ses.get_resolver().async_resolve(ps.hostname, resolver_interface::abort_on_shutdown + , [self, web, proxy_port](error_code const& e, std::vector
const& addrs) { self->wrap(&torrent::on_proxy_name_lookup, e, addrs, web, proxy_port); }); @@ -5557,7 +5554,7 @@ namespace libtorrent || ps.type == settings_pack::socks5_pw) && ps.proxy_peer_connections) { - connect_web_seed(web, tcp::endpoint(address(), std::uint16_t(port))); + connect_web_seed(web, {address(), std::uint16_t(port)}); } else { @@ -5568,8 +5565,8 @@ namespace libtorrent auto self = shared_from_this(); web->resolving = true; - m_ses.async_resolve(hostname, resolver_interface::abort_on_shutdown - , [self,web,port](error_code const& e, std::vector
const& addrs) + m_ses.get_resolver().async_resolve(hostname, resolver_interface::abort_on_shutdown + , [self, web, port](error_code const& e, std::vector
const& addrs) { self->wrap(&torrent::on_name_lookup, e, addrs, port, web); }); @@ -5653,7 +5650,7 @@ namespace libtorrent auto self = shared_from_this(); web->resolving = true; - m_ses.async_resolve(hostname, resolver_interface::abort_on_shutdown + m_ses.get_resolver().async_resolve(hostname, resolver_interface::abort_on_shutdown , [self, web, port](error_code const& err, std::vector
const& addr) { self->wrap(&torrent::on_name_lookup, err, addr, port, web);