diff --git a/ChangeLog b/ChangeLog index c2073f8cd..7c6c4c00a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -81,6 +81,7 @@ * resume data no longer has timestamps of files * require C++11 to build libtorrent + * fix support for boost-1.66 (requires C++11) * fix i2p support * fix loading resume data when in seed mode * fix part-file creation race condition diff --git a/include/libtorrent/proxy_base.hpp b/include/libtorrent/proxy_base.hpp index fd1622574..ea342c65e 100644 --- a/include/libtorrent/proxy_base.hpp +++ b/include/libtorrent/proxy_base.hpp @@ -63,6 +63,11 @@ public: m_port = port; } +#if BOOST_VERSION >= 106600 + typedef tcp::socket::executor_type executor_type; + executor_type get_executor() { return m_sock.get_executor(); } +#endif + template void async_read_some(Mutable_Buffers const& buffers, Handler const& handler) { @@ -119,6 +124,18 @@ public: m_sock.async_write_some(buffers, handler); } +#ifndef BOOST_NO_EXCEPTIONS + void non_blocking(bool b) + { + m_sock.non_blocking(b); + } +#endif + + error_code non_blocking(bool b, error_code& ec) + { + return m_sock.non_blocking(b, ec); + } + #ifndef BOOST_NO_EXCEPTIONS template void set_option(SettableSocketOption const& opt) diff --git a/include/libtorrent/socket_type.hpp b/include/libtorrent/socket_type.hpp index ce1dc64b4..de88979ac 100644 --- a/include/libtorrent/socket_type.hpp +++ b/include/libtorrent/socket_type.hpp @@ -258,6 +258,14 @@ namespace libtorrent { error_code set_option(SettableSocketOption const& opt, error_code& ec) { TORRENT_SOCKTYPE_FORWARD_RET(set_option(opt, ec), ec) } + void non_blocking(bool b, error_code& ec) + { TORRENT_SOCKTYPE_FORWARD(non_blocking(b, ec)) } + +#ifndef BOOST_NO_EXCEPTIONS + void non_blocking(bool b) + { TORRENT_SOCKTYPE_FORWARD(non_blocking(b)) } +#endif + #ifndef BOOST_NO_EXCEPTIONS template void get_option(GettableSocketOption& opt) diff --git a/include/libtorrent/ssl_stream.hpp b/include/libtorrent/ssl_stream.hpp index 7f0908d0f..31f2a5c5f 100644 --- a/include/libtorrent/ssl_stream.hpp +++ b/include/libtorrent/ssl_stream.hpp @@ -79,6 +79,10 @@ public: typedef typename Stream::lowest_layer_type lowest_layer_type; typedef typename Stream::endpoint_type endpoint_type; typedef typename Stream::protocol_type protocol_type; +#if BOOST_VERSION >= 106600 + typedef typename sock_type::executor_type executor_type; + executor_type get_executor() { return m_sock.get_executor(); } +#endif void set_host_name(std::string name) { @@ -198,6 +202,13 @@ public: m_sock.next_layer().io_control(ioc, ec); } +#ifndef BOOST_NO_EXCEPTIONS + void non_blocking(bool b) { m_sock.next_layer().non_blocking(b); } +#endif + + error_code non_blocking(bool b, error_code& ec) + { return m_sock.next_layer().non_blocking(b, ec); } + template void async_write_some(Const_Buffers const& buffers, Handler const& handler) { diff --git a/include/libtorrent/utp_stream.hpp b/include/libtorrent/utp_stream.hpp index 6d2794bf7..c5d58bbb5 100644 --- a/include/libtorrent/utp_stream.hpp +++ b/include/libtorrent/utp_stream.hpp @@ -187,6 +187,11 @@ struct TORRENT_EXTRA_EXPORT utp_stream using endpoint_type = tcp::socket::endpoint_type; using protocol_type = tcp::socket::protocol_type; +#if BOOST_VERSION >= 106600 + typedef tcp::socket::executor_type executor_type; + executor_type get_executor() { return m_io_service.get_executor(); } +#endif + explicit utp_stream(io_service& io_service); ~utp_stream(); utp_stream& operator=(utp_stream const&) = delete; @@ -208,6 +213,12 @@ struct TORRENT_EXTRA_EXPORT utp_stream template void io_control(IO_Control_Command&, error_code&) {} +#ifndef BOOST_NO_EXCEPTIONS + void non_blocking(bool) {} +#endif + + error_code non_blocking(bool, error_code&) { return error_code(); } + #ifndef BOOST_NO_EXCEPTIONS void bind(endpoint_type const& /*endpoint*/) {} #endif @@ -320,8 +331,13 @@ struct TORRENT_EXTRA_EXPORT utp_stream return; } std::size_t bytes_added = 0; +#if BOOST_VERSION >= 106600 + for (auto i = buffer_sequence_begin(buffers) + , end(buffer_sequence_end(buffers)); i != end; ++i) +#else for (typename Mutable_Buffers::const_iterator i = buffers.begin() , end(buffers.end()); i != end; ++i) +#endif { if (buffer_size(*i) == 0) continue; using boost::asio::buffer_cast; @@ -391,8 +407,13 @@ struct TORRENT_EXTRA_EXPORT utp_stream size_t buf_size = 0; #endif +#if BOOST_VERSION >= 106600 + for (auto i = buffer_sequence_begin(buffers) + , end(buffer_sequence_end(buffers)); i != end; ++i) +#else for (typename Mutable_Buffers::const_iterator i = buffers.begin() , end(buffers.end()); i != end; ++i) +#endif { using boost::asio::buffer_cast; using boost::asio::buffer_size; @@ -456,8 +477,13 @@ struct TORRENT_EXTRA_EXPORT utp_stream } std::size_t bytes_added = 0; +#if BOOST_VERSION >= 106600 + for (auto i = buffer_sequence_begin(buffers) + , end(buffer_sequence_end(buffers)); i != end; ++i) +#else for (typename Const_Buffers::const_iterator i = buffers.begin() , end(buffers.end()); i != end; ++i) +#endif { if (buffer_size(*i) == 0) continue; using boost::asio::buffer_cast; diff --git a/simulation/fake_peer.hpp b/simulation/fake_peer.hpp index 9470a4d7c..aba3eace6 100644 --- a/simulation/fake_peer.hpp +++ b/simulation/fake_peer.hpp @@ -290,7 +290,7 @@ struct udp_server m_socket.bind(asio::ip::udp::endpoint(asio::ip::address_v4::any(), port), ec); TEST_CHECK(!ec); - m_socket.io_control(lt::udp::socket::non_blocking_io(true)); + m_socket.non_blocking(true); std::printf("udp_server::async_read_some\n"); using namespace std::placeholders; diff --git a/simulation/libsimulator b/simulation/libsimulator index 84b5a4168..5688f98f7 160000 --- a/simulation/libsimulator +++ b/simulation/libsimulator @@ -1 +1 @@ -Subproject commit 84b5a4168dbc944043083b40ca662bc228b42218 +Subproject commit 5688f98f79279de6eee99ef10d54fc8e83587fe9 diff --git a/simulation/setup_dht.cpp b/simulation/setup_dht.cpp index bba91a0bc..1a1ab77cf 100644 --- a/simulation/setup_dht.cpp +++ b/simulation/setup_dht.cpp @@ -109,8 +109,7 @@ struct dht_node final : lt::dht::socket_manager sock().bind(asio::ip::udp::endpoint( m_ipv6 ? lt::address(lt::address_v6::any()) : lt::address(lt::address_v4::any()), 6881)); - udp::socket::non_blocking_io ioc(true); - sock().io_control(ioc); + sock().non_blocking(true); sock().async_receive_from(asio::mutable_buffers_1(m_buffer, sizeof(m_buffer)) , m_ep, [&](lt::error_code const& ec, std::size_t bytes_transferred) { this->on_read(ec, bytes_transferred); }); diff --git a/simulation/test_dht_rate_limit.cpp b/simulation/test_dht_rate_limit.cpp index 22617402e..962ad3581 100644 --- a/simulation/test_dht_rate_limit.cpp +++ b/simulation/test_dht_rate_limit.cpp @@ -145,7 +145,7 @@ TORRENT_TEST(dht_rate_limit) udp::socket sender_sock(sender_ios); sender_sock.open(udp::v4()); sender_sock.bind(udp::endpoint(address_v4(), 4444)); - sender_sock.io_control(udp::socket::non_blocking_io(true)); + sender_sock.non_blocking(true); asio::high_resolution_timer timer(sender_ios); std::function sender_tick = [&](error_code const&) { diff --git a/src/http_connection.cpp b/src/http_connection.cpp index f9d3e3d1c..46cd31870 100644 --- a/src/http_connection.cpp +++ b/src/http_connection.cpp @@ -326,8 +326,7 @@ void http_connection::start(std::string const& hostname, int port { if (m_ssl_ctx == nullptr) { - m_ssl_ctx = new (std::nothrow) ssl::context( - m_timer.get_io_service(), ssl::context::sslv23_client); + m_ssl_ctx = new (std::nothrow) ssl::context(ssl::context::sslv23_client); if (m_ssl_ctx) { m_own_ssl_context = true; diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index c0285f6e7..314813ef6 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -267,9 +267,8 @@ namespace libtorrent { if (!m_outgoing) { - tcp::socket::non_blocking_io ioc(true); error_code ec; - m_socket->io_control(ioc, ec); + m_socket->non_blocking(true, ec); if (ec) { disconnect(ec, operation_t::iocontrol); @@ -6059,11 +6058,10 @@ namespace libtorrent { // set the socket to non-blocking, so that we can // read the entire buffer on each read event we get - tcp::socket::non_blocking_io ioc(true); #ifndef TORRENT_DISABLE_LOGGING peer_log(peer_log_alert::info, "SET_NON_BLOCKING"); #endif - m_socket->io_control(ioc, ec); + m_socket->non_blocking(true, ec); if (ec) { disconnect(ec, operation_t::iocontrol); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 5acc08e31..6740c3e40 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -395,7 +395,7 @@ namespace aux { : m_settings(pack) , m_io_service(ios) #ifdef TORRENT_USE_OPENSSL - , m_ssl_ctx(m_io_service, boost::asio::ssl::context::sslv23) + , m_ssl_ctx(boost::asio::ssl::context::sslv23) #endif , m_alerts(m_settings.get_int(settings_pack::alert_queue_size) , alert_category_t{static_cast(m_settings.get_int(settings_pack::alert_mask))}) diff --git a/src/torrent.cpp b/src/torrent.cpp index 64684292d..e2c684678 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1544,7 +1544,7 @@ namespace libtorrent { // create the SSL context for this torrent. We need to // inject the root certificate, and no other, to // verify other peers against - std::shared_ptr ctx = std::make_shared(m_ses.get_io_service(), context::sslv23); + std::shared_ptr ctx = std::make_shared(context::sslv23); if (!ctx) { @@ -1581,7 +1581,7 @@ namespace libtorrent { return; } - SSL_CTX* ssl_ctx = ctx->impl(); + SSL_CTX* ssl_ctx = ctx->native_handle(); // create a new x.509 certificate store X509_STORE* cert_store = X509_STORE_new(); if (!cert_store) diff --git a/src/udp_socket.cpp b/src/udp_socket.cpp index a6607033a..deeb8548c 100644 --- a/src/udp_socket.cpp +++ b/src/udp_socket.cpp @@ -447,8 +447,7 @@ void udp_socket::bind(udp::endpoint const& ep, error_code& ec) if (ec) return; m_socket.bind(ep, ec); if (ec) return; - udp::socket::non_blocking_io ioc(true); - m_socket.io_control(ioc, ec); + m_socket.non_blocking(true, ec); if (ec) return; error_code err; diff --git a/test/test_ssl.cpp b/test/test_ssl.cpp index e8aa9e731..b65119af4 100644 --- a/test/test_ssl.cpp +++ b/test/test_ssl.cpp @@ -369,7 +369,7 @@ bool try_connect(lt::session& ses1, int port // create the SSL context for this torrent. We need to // inject the root certificate, and no other, to // verify other peers against - context ctx(ios, context::sslv23); + context ctx(context::sslv23); ctx.set_options(context::default_workarounds | boost::asio::ssl::context::no_sslv2