diff --git a/libtorrent/include/libtorrent/io_service.hpp b/libtorrent/include/libtorrent/io_service.hpp index 9bdcca7f..0ce79f38 100644 --- a/libtorrent/include/libtorrent/io_service.hpp +++ b/libtorrent/include/libtorrent/io_service.hpp @@ -62,6 +62,8 @@ POSSIBILITY OF SUCH DAMAGE. #undef Protocol #endif +#include "libtorrent/io_service_fwd.hpp" + namespace libtorrent { diff --git a/libtorrent/include/libtorrent/io_service_fwd.hpp b/libtorrent/include/libtorrent/io_service_fwd.hpp index 3325c7e5..0a131811 100644 --- a/libtorrent/include/libtorrent/io_service_fwd.hpp +++ b/libtorrent/include/libtorrent/io_service_fwd.hpp @@ -75,6 +75,15 @@ namespace libtorrent #else typedef boost::asio::io_service 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 diff --git a/libtorrent/include/libtorrent/proxy_base.hpp b/libtorrent/include/libtorrent/proxy_base.hpp index fb431e61..e53a0b8f 100644 --- a/libtorrent/include/libtorrent/proxy_base.hpp +++ b/libtorrent/include/libtorrent/proxy_base.hpp @@ -229,7 +229,7 @@ public: io_service& get_io_service() { - return m_sock.get_io_service(); + return libtorrent::get_io_service(m_sock); } lowest_layer_type& lowest_layer() diff --git a/libtorrent/include/libtorrent/socket_type.hpp b/libtorrent/include/libtorrent/socket_type.hpp index b325b52c..5ebd9bfb 100644 --- a/libtorrent/include/libtorrent/socket_type.hpp +++ b/libtorrent/include/libtorrent/socket_type.hpp @@ -182,7 +182,11 @@ namespace libtorrent { typedef stream_socket::endpoint_type endpoint_type; typedef stream_socket::protocol_type protocol_type; - + +#if BOOST_VERSION >= 106600 + typedef tcp::socket::executor_type executor_type; +#endif + explicit socket_type(io_service& ios): m_io_service(ios), m_type(0) {} ~socket_type(); diff --git a/libtorrent/include/libtorrent/ssl_stream.hpp b/libtorrent/include/libtorrent/ssl_stream.hpp index 96a0808b..1bf23b52 100644 --- a/libtorrent/include/libtorrent/ssl_stream.hpp +++ b/libtorrent/include/libtorrent/ssl_stream.hpp @@ -258,7 +258,7 @@ public: io_service& get_io_service() { - return m_sock.get_io_service(); + return get_io_service(m_sock); } lowest_layer_type& lowest_layer() diff --git a/libtorrent/include/libtorrent/udp_socket.hpp b/libtorrent/include/libtorrent/udp_socket.hpp index e9cb2e86..01ab14c0 100644 --- a/libtorrent/include/libtorrent/udp_socket.hpp +++ b/libtorrent/include/libtorrent/udp_socket.hpp @@ -80,7 +80,8 @@ namespace libtorrent #endif ; } - io_service& get_io_service() { return m_ipv4_sock.get_io_service(); } + io_service& get_io_service() { return libtorrent::get_io_service(m_ipv4_sock); } + udp::socket::executor_type get_executor() { return m_ipv4_sock.get_executor(); } void subscribe(udp_socket_observer* o); void unsubscribe(udp_socket_observer* o); diff --git a/libtorrent/src/connection_queue.cpp b/libtorrent/src/connection_queue.cpp index 96aceffa..a4bff0bd 100644 --- a/libtorrent/src/connection_queue.cpp +++ b/libtorrent/src/connection_queue.cpp @@ -100,7 +100,7 @@ namespace libtorrent if (m_num_connecting < m_half_open_limit || m_half_open_limit == 0) - m_timer.get_io_service().post(boost::bind( + get_io_service(m_timer).post(boost::bind( &connection_queue::on_try_connect, this)); } @@ -122,7 +122,7 @@ namespace libtorrent if (m_num_connecting < m_half_open_limit || m_half_open_limit == 0) - m_timer.get_io_service().post(boost::bind( + get_io_service(m_timer).post(boost::bind( &connection_queue::on_try_connect, this)); } diff --git a/libtorrent/src/http_connection.cpp b/libtorrent/src/http_connection.cpp index 28595506..4d3d9a5c 100644 --- a/libtorrent/src/http_connection.cpp +++ b/libtorrent/src/http_connection.cpp @@ -134,14 +134,14 @@ void http_connection::get(std::string const& url, time_duration timeout, int pri ) { error_code ec(errors::unsupported_url_protocol); - m_resolver.get_io_service().post(boost::bind(&http_connection::callback + get_io_service(m_resolver).post(boost::bind(&http_connection::callback , me, ec, (char*)0, 0)); return; } if (ec) { - m_resolver.get_io_service().post(boost::bind(&http_connection::callback + get_io_service(m_resolver).post(boost::bind(&http_connection::callback , me, ec, (char*)0, 0)); return; } @@ -239,7 +239,7 @@ void http_connection::start(std::string const& hostname, std::string const& port if (ec) { - m_resolver.get_io_service().post(boost::bind(&http_connection::callback + get_io_service(m_resolver).post(boost::bind(&http_connection::callback , me, ec, (char*)0, 0)); return; } @@ -279,7 +279,7 @@ void http_connection::start(std::string const& hostname, std::string const& port #if TORRENT_USE_I2P if (is_i2p && i2p_conn->proxy().type != proxy_settings::i2p_proxy) { - m_resolver.get_io_service().post(boost::bind(&http_connection::callback + get_io_service(m_resolver).post(boost::bind(&http_connection::callback , me, error_code(errors::no_i2p_router, get_libtorrent_category()), (char*)0, 0)); return; } @@ -319,7 +319,7 @@ void http_connection::start(std::string const& hostname, std::string const& port userdata = m_ssl_ctx; } #endif - instantiate_connection(m_resolver.get_io_service() + instantiate_connection(get_io_service(m_resolver) , proxy ? *proxy : null_proxy, m_sock, userdata); if (m_bind_addr != address_v4::any()) @@ -329,7 +329,7 @@ void http_connection::start(std::string const& hostname, std::string const& port m_sock.bind(tcp::endpoint(m_bind_addr, 0), ec); if (ec) { - m_resolver.get_io_service().post(boost::bind(&http_connection::callback + get_io_service(m_resolver).post(boost::bind(&http_connection::callback , me, ec, (char*)0, 0)); return; } @@ -338,7 +338,7 @@ void http_connection::start(std::string const& hostname, std::string const& port setup_ssl_hostname(m_sock, hostname, ec); if (ec) { - m_resolver.get_io_service().post(boost::bind(&http_connection::callback + get_io_service(m_resolver).post(boost::bind(&http_connection::callback , me, ec, (char*)0, 0)); return; } diff --git a/libtorrent/src/kademlia/dht_tracker.cpp b/libtorrent/src/kademlia/dht_tracker.cpp index e64caa36..82148973 100644 --- a/libtorrent/src/kademlia/dht_tracker.cpp +++ b/libtorrent/src/kademlia/dht_tracker.cpp @@ -208,13 +208,13 @@ namespace libtorrent { namespace dht , ses.external_address().external_address(address_v4()), &ses) , m_sock(sock) , m_last_new_key(time_now() - minutes(key_refresh)) - , m_timer(sock.get_io_service()) - , m_connection_timer(sock.get_io_service()) - , m_refresh_timer(sock.get_io_service()) + , m_timer(get_io_service(sock)) + , m_connection_timer(get_io_service(sock)) + , m_refresh_timer(get_io_service(sock)) , m_settings(settings) , m_refresh_bucket(160) , m_abort(false) - , m_host_resolver(sock.get_io_service()) + , m_host_resolver(get_io_service(sock)) , m_sent_bytes(0) , m_received_bytes(0) , m_refs(0) diff --git a/libtorrent/src/natpmp.cpp b/libtorrent/src/natpmp.cpp index 9893f74c..4d33e426 100644 --- a/libtorrent/src/natpmp.cpp +++ b/libtorrent/src/natpmp.cpp @@ -90,7 +90,7 @@ void natpmp::rebind(address const& listen_interface) 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(get_io_service(m_socket), ec); if (ec) { char msg[200]; diff --git a/libtorrent/src/utp_socket_manager.cpp b/libtorrent/src/utp_socket_manager.cpp index 0c8e0519..ce872818 100644 --- a/libtorrent/src/utp_socket_manager.cpp +++ b/libtorrent/src/utp_socket_manager.cpp @@ -111,7 +111,7 @@ namespace libtorrent { m_last_route_update = time_now(); error_code ec; - m_routes = enum_routes(m_sock.get_io_service(), ec); + m_routes = enum_routes(get_io_service(m_sock), ec); } int mtu = 0; @@ -220,7 +220,7 @@ namespace libtorrent { m_last_route_update = time_now(); error_code ec; - m_routes = enum_routes(m_sock.get_io_service(), ec); + m_routes = enum_routes(get_io_service(m_sock), ec); if (ec) return socket_ep; } @@ -251,7 +251,7 @@ namespace libtorrent { m_last_if_update = time_now(); error_code ec; - m_interfaces = enum_net_interfaces(m_sock.get_io_service(), ec); + m_interfaces = enum_net_interfaces(get_io_service(m_sock), ec); if (ec) return socket_ep; } @@ -320,14 +320,14 @@ namespace libtorrent // UTP_LOGV("not found, new connection id:%d\n", m_new_connection); - boost::shared_ptr c(new (std::nothrow) socket_type(m_sock.get_io_service())); + boost::shared_ptr c(new (std::nothrow) socket_type(get_io_service(m_sock))); if (!c) return false; TORRENT_ASSERT(m_new_connection == -1); // create the new socket with this ID m_new_connection = id; - instantiate_connection(m_sock.get_io_service(), proxy_settings(), *c, 0, this); + instantiate_connection(get_io_service(m_sock), proxy_settings(), *c, 0, this); utp_stream* str = c->get(); TORRENT_ASSERT(str); int link_mtu, utp_mtu; diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 01b168cc..15b96d34 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -645,7 +645,11 @@ public: } bool connect(const std::string& server, const std::string& port) { +#if BOOST_VERSION >= 107000 + ip::tcp::resolver resolver(static_cast(stream.get_executor().context())); +#else ip::tcp::resolver resolver(stream.get_io_service()); +#endif ip::tcp::resolver::query query(server.c_str(), port.c_str()); ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve(query); ip::tcp::resolver::iterator end; @@ -732,7 +736,11 @@ static void RPCListen(boost::shared_ptr< basic_socket_acceptor > accep const bool fUseSSL) { // Accept connection +#if BOOST_VERSION >= 107000 + AcceptedConnectionImpl* conn = new AcceptedConnectionImpl(static_cast(acceptor->get_executor().context()), context, fUseSSL); +#else AcceptedConnectionImpl* conn = new AcceptedConnectionImpl(acceptor->get_io_service(), context, fUseSSL); +#endif acceptor->async_accept( conn->sslStream.lowest_layer(),