https://github.com/arvidn/libtorrent/commit/76c2794923c4 --- include/libtorrent/io_service.hpp.orig 2018-10-05 09:19:18 UTC +++ include/libtorrent/io_service.hpp @@ -53,6 +53,7 @@ POSSIBILITY OF SUCH DAMAGE. #endif #include "libtorrent/aux_/disable_warnings_pop.hpp" +#include "libtorrent/io_service_fwd.hpp" #ifdef __OBJC__ #undef Protocol --- include/libtorrent/io_service_fwd.hpp.orig 2018-10-05 09:19:18 UTC +++ include/libtorrent/io_service_fwd.hpp @@ -65,10 +65,19 @@ namespace boost { namespace asio { namespace libtorrent { #if defined TORRENT_BUILD_SIMULATOR - typedef sim::asio::io_service io_service; + using io_service = sim::asio::io_service; #else - typedef boost::asio::io_service io_service; + using io_service = boost::asio::io_service; #endif + +#if BOOST_VERSION >= 107000 +template +io_service& get_io_service(T& o) { return static_cast(o.get_executor().context()); } +#else +template +io_service& get_io_service(T& o) { return o.get_io_service(); } +#endif + } #endif --- include/libtorrent/proxy_base.hpp.orig 2018-10-05 09:19:18 UTC +++ include/libtorrent/proxy_base.hpp @@ -249,7 +249,7 @@ class proxy_base : boost::noncopyable (public) io_service& get_io_service() { - return m_sock.get_io_service(); + return lt::get_io_service(m_sock); } lowest_layer_type& lowest_layer() --- include/libtorrent/tracker_manager.hpp.orig 2018-10-05 09:19:21 UTC +++ include/libtorrent/tracker_manager.hpp @@ -283,7 +283,7 @@ namespace libtorrent virtual void on_timeout(error_code const& ec) = 0; virtual ~timeout_handler() {} - io_service& get_io_service() { return m_timeout.get_io_service(); } + io_service& get_io_service() { return lt::get_io_service(m_timeout); } private: --- include/libtorrent/udp_socket.hpp.orig 2018-10-05 09:19:18 UTC +++ include/libtorrent/udp_socket.hpp @@ -80,7 +80,7 @@ namespace libtorrent }; bool is_open() const { return m_abort == false; } - io_service& get_io_service() { return m_ipv4_sock.get_io_service(); } + io_service& get_io_service() { return lt::get_io_service(m_ipv4_sock); } void subscribe(udp_socket_observer* o); void unsubscribe(udp_socket_observer* o); --- src/http_connection.cpp.orig 2018-10-05 09:19:18 UTC +++ src/http_connection.cpp @@ -150,7 +150,7 @@ void http_connection::get(std::string const& url, time if (ec) { - m_timer.get_io_service().post(boost::bind(&http_connection::callback + lt::get_io_service(m_timer).post(boost::bind(&http_connection::callback , me, ec, static_cast(NULL), 0)); return; } @@ -162,7 +162,7 @@ void http_connection::get(std::string const& url, time ) { error_code err(errors::unsupported_url_protocol); - m_timer.get_io_service().post(boost::bind(&http_connection::callback + lt::get_io_service(m_timer).post(boost::bind(&http_connection::callback , me, err, static_cast(NULL), 0)); return; } @@ -263,7 +263,7 @@ void http_connection::start(std::string const& hostnam if (ec) { - m_timer.get_io_service().post(boost::bind(&http_connection::callback + lt::get_io_service(m_timer).post(boost::bind(&http_connection::callback , me, ec, static_cast(NULL), 0)); return; } @@ -303,7 +303,7 @@ void http_connection::start(std::string const& hostnam if (i2p_conn->proxy().type != settings_pack::i2p_proxy) { - m_timer.get_io_service().post(boost::bind(&http_connection::callback + lt::get_io_service(m_timer).post(boost::bind(&http_connection::callback , me, error_code(errors::no_i2p_router), static_cast(NULL), 0)); return; } @@ -337,7 +337,7 @@ void http_connection::start(std::string const& hostnam m_ssl_ctx->set_verify_mode(ssl::context::verify_none, ec); if (ec) { - m_timer.get_io_service().post(boost::bind(&http_connection::callback + lt::get_io_service(m_timer).post(boost::bind(&http_connection::callback , me, ec, static_cast(NULL), 0)); return; } @@ -349,7 +349,7 @@ void http_connection::start(std::string const& hostnam // assume this is not a tracker connection. Tracker connections that // shouldn't be subject to the proxy should pass in NULL as the proxy // pointer. - instantiate_connection(m_timer.get_io_service() + instantiate_connection(lt::get_io_service(m_timer) , proxy ? *proxy : null_proxy, m_sock, userdata, NULL, false, false); if (m_bind_addr) @@ -358,7 +358,7 @@ void http_connection::start(std::string const& hostnam m_sock.bind(tcp::endpoint(*m_bind_addr, 0), ec); if (ec) { - m_timer.get_io_service().post(boost::bind(&http_connection::callback + lt::get_io_service(m_timer).post(boost::bind(&http_connection::callback , me, ec, static_cast(NULL), 0)); return; } @@ -367,7 +367,7 @@ void http_connection::start(std::string const& hostnam setup_ssl_hostname(m_sock, hostname, ec); if (ec) { - m_timer.get_io_service().post(boost::bind(&http_connection::callback + lt::get_io_service(m_timer).post(boost::bind(&http_connection::callback , me, ec, static_cast(NULL), 0)); return; } --- src/lsd.cpp.orig 2018-10-05 09:19:18 UTC +++ src/lsd.cpp @@ -112,12 +112,12 @@ void lsd::debug_log(char const* fmt, ...) const void lsd::start(error_code& ec) { m_socket.open(boost::bind(&lsd::on_announce, self(), _1, _2, _3) - , m_broadcast_timer.get_io_service(), ec); + , lt::get_io_service(m_broadcast_timer), ec); if (ec) return; #if TORRENT_USE_IPV6 m_socket6.open(boost::bind(&lsd::on_announce, self(), _1, _2, _3) - , m_broadcast_timer.get_io_service(), ec); + , lt::get_io_service(m_broadcast_timer), ec); #endif } --- src/natpmp.cpp.orig 2018-10-05 09:19:18 UTC +++ src/natpmp.cpp @@ -89,7 +89,7 @@ void natpmp::start() mutex::scoped_lock l(m_mutex); error_code ec; - address gateway = get_default_gateway(m_socket.get_io_service(), ec); + address gateway = get_default_gateway(lt::get_io_service(m_socket), ec); if (ec) { char msg[200]; --- src/upnp.cpp.orig 2018-10-05 09:19:18 UTC +++ src/upnp.cpp @@ -135,7 +135,7 @@ void upnp::start() { error_code ec; m_socket.open(boost::bind(&upnp::on_reply, self(), _1, _2, _3) - , m_refresh_timer.get_io_service(), ec); + , lt::get_io_service(m_refresh_timer), ec); m_mappings.reserve(10); } --- test/test_fast_extension.cpp.orig 2018-10-05 09:19:21 UTC +++ test/test_fast_extension.cpp @@ -453,7 +453,7 @@ boost::shared_ptr setup_peer(tcp::socket } else { - tcp::acceptor l(s.get_io_service()); + tcp::acceptor l(lt::get_io_service(s)); l.open(tcp::v4()); l.bind(tcp::endpoint(address_v4::from_string("127.0.0.1") , 3000 + rand() % 60000));