fix build against boost-1.66, specifically the boost.asio changes

This commit is contained in:
arvidn 2017-12-14 01:37:27 +01:00 committed by Arvid Norberg
parent 86c83fe976
commit d1a63cd781
14 changed files with 75 additions and 19 deletions

View File

@ -1,4 +1,5 @@
* 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

View File

@ -66,6 +66,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 <class Mutable_Buffers, class Handler>
void async_read_some(Mutable_Buffers const& buffers, Handler const& handler)
{
@ -122,6 +127,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 <class SettableSocketOption>
void set_option(SettableSocketOption const& opt)

View File

@ -267,6 +267,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 <class GettableSocketOption>
void get_option(GettableSocketOption& opt)

View File

@ -85,6 +85,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)
{
@ -204,6 +208,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 <class Const_Buffers, class Handler>
void async_write_some(Const_Buffers const& buffers, Handler const& handler)
{

View File

@ -201,6 +201,11 @@ public:
typedef tcp::socket::endpoint_type endpoint_type;
typedef tcp::socket::protocol_type 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();
@ -218,6 +223,12 @@ public:
template <class IO_Control_Command>
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
@ -330,8 +341,13 @@ public:
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;
@ -401,8 +417,13 @@ public:
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;
@ -466,8 +487,13 @@ public:
}
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;

View File

@ -194,7 +194,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;

@ -1 +1 @@
Subproject commit 96e8e2414df955c04b37b6bccd2b7360a54ff2f1
Subproject commit de7e1e3914a097f3f7a0c8156447f5149bd8e447

View File

@ -94,9 +94,7 @@ struct dht_node final : lt::dht::udp_socket_interface
error_code ec;
sock().open(asio::ip::udp::v4());
sock().bind(asio::ip::udp::endpoint(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, boost::bind(&dht_node::on_read, this, _1, _2));

View File

@ -330,8 +330,7 @@ void http_connection::start(std::string const& hostname, int port
{
if (m_ssl_ctx == 0)
{
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;

View File

@ -309,9 +309,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, op_iocontrol);
@ -6406,11 +6405,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, op_iocontrol);

View File

@ -346,7 +346,7 @@ namespace aux {
#endif
, 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)
, m_settings.get_int(settings_pack::alert_mask))

View File

@ -1702,7 +1702,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
boost::shared_ptr<context> ctx = boost::make_shared<context>(boost::ref(m_ses.get_io_service()), context::sslv23);
boost::shared_ptr<context> ctx = boost::make_shared<context>(context::sslv23);
if (!ctx)
{
@ -1739,7 +1739,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)

View File

@ -806,8 +806,7 @@ void udp_socket::bind(udp::endpoint const& ep, error_code& ec)
m_ipv4_sock.bind(ep, ec);
if (ec) return;
udp::socket::non_blocking_io ioc(true);
m_ipv4_sock.io_control(ioc, ec);
m_ipv4_sock.non_blocking(true, ec);
if (ec) return;
setup_read(&m_ipv4_sock);
}
@ -837,8 +836,7 @@ void udp_socket::bind(udp::endpoint const& ep, error_code& ec)
, boost::system::generic_category()))
{
if (ec) return;
udp::socket::non_blocking_io ioc(true);
m_ipv6_sock.io_control(ioc, ec);
m_ipv6_sock.non_blocking(true, ec);
if (ec) return;
setup_read(&m_ipv6_sock);
}

View File

@ -363,7 +363,7 @@ bool try_connect(libtorrent::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