Skip to content

Commit 55babc5

Browse files
committed
merged RC_1_1 into master
2 parents ba224a1 + d1a63cd commit 55babc5

15 files changed

+75
-17
lines changed

ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
* resume data no longer has timestamps of files
8282
* require C++11 to build libtorrent
8383

84+
* fix support for boost-1.66 (requires C++11)
8485
* fix i2p support
8586
* fix loading resume data when in seed mode
8687
* fix part-file creation race condition

include/libtorrent/proxy_base.hpp

+17
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ class proxy_base
6363
m_port = port;
6464
}
6565

66+
#if BOOST_VERSION >= 106600
67+
typedef tcp::socket::executor_type executor_type;
68+
executor_type get_executor() { return m_sock.get_executor(); }
69+
#endif
70+
6671
template <class Mutable_Buffers, class Handler>
6772
void async_read_some(Mutable_Buffers const& buffers, Handler const& handler)
6873
{
@@ -119,6 +124,18 @@ class proxy_base
119124
m_sock.async_write_some(buffers, handler);
120125
}
121126

127+
#ifndef BOOST_NO_EXCEPTIONS
128+
void non_blocking(bool b)
129+
{
130+
m_sock.non_blocking(b);
131+
}
132+
#endif
133+
134+
error_code non_blocking(bool b, error_code& ec)
135+
{
136+
return m_sock.non_blocking(b, ec);
137+
}
138+
122139
#ifndef BOOST_NO_EXCEPTIONS
123140
template <class SettableSocketOption>
124141
void set_option(SettableSocketOption const& opt)

include/libtorrent/socket_type.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,14 @@ namespace libtorrent {
258258
error_code set_option(SettableSocketOption const& opt, error_code& ec)
259259
{ TORRENT_SOCKTYPE_FORWARD_RET(set_option(opt, ec), ec) }
260260

261+
void non_blocking(bool b, error_code& ec)
262+
{ TORRENT_SOCKTYPE_FORWARD(non_blocking(b, ec)) }
263+
264+
#ifndef BOOST_NO_EXCEPTIONS
265+
void non_blocking(bool b)
266+
{ TORRENT_SOCKTYPE_FORWARD(non_blocking(b)) }
267+
#endif
268+
261269
#ifndef BOOST_NO_EXCEPTIONS
262270
template <class GettableSocketOption>
263271
void get_option(GettableSocketOption& opt)

include/libtorrent/ssl_stream.hpp

+11
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ class ssl_stream
7979
typedef typename Stream::lowest_layer_type lowest_layer_type;
8080
typedef typename Stream::endpoint_type endpoint_type;
8181
typedef typename Stream::protocol_type protocol_type;
82+
#if BOOST_VERSION >= 106600
83+
typedef typename sock_type::executor_type executor_type;
84+
executor_type get_executor() { return m_sock.get_executor(); }
85+
#endif
8286

8387
void set_host_name(std::string name)
8488
{
@@ -198,6 +202,13 @@ class ssl_stream
198202
m_sock.next_layer().io_control(ioc, ec);
199203
}
200204

205+
#ifndef BOOST_NO_EXCEPTIONS
206+
void non_blocking(bool b) { m_sock.next_layer().non_blocking(b); }
207+
#endif
208+
209+
error_code non_blocking(bool b, error_code& ec)
210+
{ return m_sock.next_layer().non_blocking(b, ec); }
211+
201212
template <class Const_Buffers, class Handler>
202213
void async_write_some(Const_Buffers const& buffers, Handler const& handler)
203214
{

include/libtorrent/utp_stream.hpp

+26
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ struct TORRENT_EXTRA_EXPORT utp_stream
187187
using endpoint_type = tcp::socket::endpoint_type;
188188
using protocol_type = tcp::socket::protocol_type;
189189

190+
#if BOOST_VERSION >= 106600
191+
typedef tcp::socket::executor_type executor_type;
192+
executor_type get_executor() { return m_io_service.get_executor(); }
193+
#endif
194+
190195
explicit utp_stream(io_service& io_service);
191196
~utp_stream();
192197
utp_stream& operator=(utp_stream const&) = delete;
@@ -208,6 +213,12 @@ struct TORRENT_EXTRA_EXPORT utp_stream
208213
template <class IO_Control_Command>
209214
void io_control(IO_Control_Command&, error_code&) {}
210215

216+
#ifndef BOOST_NO_EXCEPTIONS
217+
void non_blocking(bool) {}
218+
#endif
219+
220+
error_code non_blocking(bool, error_code&) { return error_code(); }
221+
211222
#ifndef BOOST_NO_EXCEPTIONS
212223
void bind(endpoint_type const& /*endpoint*/) {}
213224
#endif
@@ -320,8 +331,13 @@ struct TORRENT_EXTRA_EXPORT utp_stream
320331
return;
321332
}
322333
std::size_t bytes_added = 0;
334+
#if BOOST_VERSION >= 106600
335+
for (auto i = buffer_sequence_begin(buffers)
336+
, end(buffer_sequence_end(buffers)); i != end; ++i)
337+
#else
323338
for (typename Mutable_Buffers::const_iterator i = buffers.begin()
324339
, end(buffers.end()); i != end; ++i)
340+
#endif
325341
{
326342
if (buffer_size(*i) == 0) continue;
327343
using boost::asio::buffer_cast;
@@ -391,8 +407,13 @@ struct TORRENT_EXTRA_EXPORT utp_stream
391407
size_t buf_size = 0;
392408
#endif
393409

410+
#if BOOST_VERSION >= 106600
411+
for (auto i = buffer_sequence_begin(buffers)
412+
, end(buffer_sequence_end(buffers)); i != end; ++i)
413+
#else
394414
for (typename Mutable_Buffers::const_iterator i = buffers.begin()
395415
, end(buffers.end()); i != end; ++i)
416+
#endif
396417
{
397418
using boost::asio::buffer_cast;
398419
using boost::asio::buffer_size;
@@ -456,8 +477,13 @@ struct TORRENT_EXTRA_EXPORT utp_stream
456477
}
457478

458479
std::size_t bytes_added = 0;
480+
#if BOOST_VERSION >= 106600
481+
for (auto i = buffer_sequence_begin(buffers)
482+
, end(buffer_sequence_end(buffers)); i != end; ++i)
483+
#else
459484
for (typename Const_Buffers::const_iterator i = buffers.begin()
460485
, end(buffers.end()); i != end; ++i)
486+
#endif
461487
{
462488
if (buffer_size(*i) == 0) continue;
463489
using boost::asio::buffer_cast;

simulation/fake_peer.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ struct udp_server
290290
m_socket.bind(asio::ip::udp::endpoint(asio::ip::address_v4::any(), port), ec);
291291
TEST_CHECK(!ec);
292292

293-
m_socket.io_control(lt::udp::socket::non_blocking_io(true));
293+
m_socket.non_blocking(true);
294294

295295
std::printf("udp_server::async_read_some\n");
296296
using namespace std::placeholders;

simulation/setup_dht.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ struct dht_node final : lt::dht::socket_manager
109109
sock().bind(asio::ip::udp::endpoint(
110110
m_ipv6 ? lt::address(lt::address_v6::any()) : lt::address(lt::address_v4::any()), 6881));
111111

112-
udp::socket::non_blocking_io ioc(true);
113-
sock().io_control(ioc);
112+
sock().non_blocking(true);
114113
sock().async_receive_from(asio::mutable_buffers_1(m_buffer, sizeof(m_buffer))
115114
, m_ep, [&](lt::error_code const& ec, std::size_t bytes_transferred)
116115
{ this->on_read(ec, bytes_transferred); });

simulation/test_dht_rate_limit.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ TORRENT_TEST(dht_rate_limit)
145145
udp::socket sender_sock(sender_ios);
146146
sender_sock.open(udp::v4());
147147
sender_sock.bind(udp::endpoint(address_v4(), 4444));
148-
sender_sock.io_control(udp::socket::non_blocking_io(true));
148+
sender_sock.non_blocking(true);
149149
asio::high_resolution_timer timer(sender_ios);
150150
std::function<void(error_code const&)> sender_tick = [&](error_code const&)
151151
{

src/http_connection.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,7 @@ void http_connection::start(std::string const& hostname, int port
326326
{
327327
if (m_ssl_ctx == nullptr)
328328
{
329-
m_ssl_ctx = new (std::nothrow) ssl::context(
330-
m_timer.get_io_service(), ssl::context::sslv23_client);
329+
m_ssl_ctx = new (std::nothrow) ssl::context(ssl::context::sslv23_client);
331330
if (m_ssl_ctx)
332331
{
333332
m_own_ssl_context = true;

src/peer_connection.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,8 @@ namespace libtorrent {
267267

268268
if (!m_outgoing)
269269
{
270-
tcp::socket::non_blocking_io ioc(true);
271270
error_code ec;
272-
m_socket->io_control(ioc, ec);
271+
m_socket->non_blocking(true, ec);
273272
if (ec)
274273
{
275274
disconnect(ec, operation_t::iocontrol);
@@ -6059,11 +6058,10 @@ namespace libtorrent {
60596058

60606059
// set the socket to non-blocking, so that we can
60616060
// read the entire buffer on each read event we get
6062-
tcp::socket::non_blocking_io ioc(true);
60636061
#ifndef TORRENT_DISABLE_LOGGING
60646062
peer_log(peer_log_alert::info, "SET_NON_BLOCKING");
60656063
#endif
6066-
m_socket->io_control(ioc, ec);
6064+
m_socket->non_blocking(true, ec);
60676065
if (ec)
60686066
{
60696067
disconnect(ec, operation_t::iocontrol);

src/session_impl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ namespace aux {
395395
: m_settings(pack)
396396
, m_io_service(ios)
397397
#ifdef TORRENT_USE_OPENSSL
398-
, m_ssl_ctx(m_io_service, boost::asio::ssl::context::sslv23)
398+
, m_ssl_ctx(boost::asio::ssl::context::sslv23)
399399
#endif
400400
, m_alerts(m_settings.get_int(settings_pack::alert_queue_size)
401401
, alert_category_t{static_cast<unsigned int>(m_settings.get_int(settings_pack::alert_mask))})

src/torrent.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ namespace libtorrent {
15441544
// create the SSL context for this torrent. We need to
15451545
// inject the root certificate, and no other, to
15461546
// verify other peers against
1547-
std::shared_ptr<context> ctx = std::make_shared<context>(m_ses.get_io_service(), context::sslv23);
1547+
std::shared_ptr<context> ctx = std::make_shared<context>(context::sslv23);
15481548

15491549
if (!ctx)
15501550
{
@@ -1581,7 +1581,7 @@ namespace libtorrent {
15811581
return;
15821582
}
15831583

1584-
SSL_CTX* ssl_ctx = ctx->impl();
1584+
SSL_CTX* ssl_ctx = ctx->native_handle();
15851585
// create a new x.509 certificate store
15861586
X509_STORE* cert_store = X509_STORE_new();
15871587
if (!cert_store)

src/udp_socket.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,7 @@ void udp_socket::bind(udp::endpoint const& ep, error_code& ec)
447447
if (ec) return;
448448
m_socket.bind(ep, ec);
449449
if (ec) return;
450-
udp::socket::non_blocking_io ioc(true);
451-
m_socket.io_control(ioc, ec);
450+
m_socket.non_blocking(true, ec);
452451
if (ec) return;
453452

454453
error_code err;

test/test_ssl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ bool try_connect(lt::session& ses1, int port
369369
// create the SSL context for this torrent. We need to
370370
// inject the root certificate, and no other, to
371371
// verify other peers against
372-
context ctx(ios, context::sslv23);
372+
context ctx(context::sslv23);
373373

374374
ctx.set_options(context::default_workarounds
375375
| boost::asio::ssl::context::no_sslv2

0 commit comments

Comments
 (0)