mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-08 22:08:00 +00:00
Merge pull request #438 from Chocobo1/libtorrent
Fix building with boost >= 1.70
This commit is contained in:
commit
5717b885a5
@ -62,6 +62,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#undef Protocol
|
#undef Protocol
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "libtorrent/io_service_fwd.hpp"
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -75,6 +75,15 @@ namespace libtorrent
|
|||||||
#else
|
#else
|
||||||
typedef boost::asio::io_service io_service;
|
typedef boost::asio::io_service io_service;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if BOOST_VERSION >= 107000
|
||||||
|
template <typename T>
|
||||||
|
io_service& get_io_service(T& o) { return static_cast<io_service&>(o.get_executor().context()); }
|
||||||
|
#else
|
||||||
|
template <typename T>
|
||||||
|
io_service& get_io_service(T& o) { return o.get_io_service(); }
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -229,7 +229,7 @@ public:
|
|||||||
|
|
||||||
io_service& get_io_service()
|
io_service& get_io_service()
|
||||||
{
|
{
|
||||||
return m_sock.get_io_service();
|
return libtorrent::get_io_service(m_sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
lowest_layer_type& lowest_layer()
|
lowest_layer_type& lowest_layer()
|
||||||
|
@ -183,6 +183,10 @@ namespace libtorrent
|
|||||||
typedef stream_socket::endpoint_type endpoint_type;
|
typedef stream_socket::endpoint_type endpoint_type;
|
||||||
typedef stream_socket::protocol_type protocol_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) {}
|
explicit socket_type(io_service& ios): m_io_service(ios), m_type(0) {}
|
||||||
~socket_type();
|
~socket_type();
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ public:
|
|||||||
|
|
||||||
io_service& get_io_service()
|
io_service& get_io_service()
|
||||||
{
|
{
|
||||||
return m_sock.get_io_service();
|
return get_io_service(m_sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
lowest_layer_type& lowest_layer()
|
lowest_layer_type& lowest_layer()
|
||||||
|
@ -80,7 +80,8 @@ namespace libtorrent
|
|||||||
#endif
|
#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 subscribe(udp_socket_observer* o);
|
||||||
void unsubscribe(udp_socket_observer* o);
|
void unsubscribe(udp_socket_observer* o);
|
||||||
|
@ -100,7 +100,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
if (m_num_connecting < m_half_open_limit
|
if (m_num_connecting < m_half_open_limit
|
||||||
|| m_half_open_limit == 0)
|
|| 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));
|
&connection_queue::on_try_connect, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
if (m_num_connecting < m_half_open_limit
|
if (m_num_connecting < m_half_open_limit
|
||||||
|| m_half_open_limit == 0)
|
|| 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));
|
&connection_queue::on_try_connect, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,14 +134,14 @@ void http_connection::get(std::string const& url, time_duration timeout, int pri
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
error_code ec(errors::unsupported_url_protocol);
|
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));
|
, me, ec, (char*)0, 0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (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));
|
, me, ec, (char*)0, 0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -239,7 +239,7 @@ void http_connection::start(std::string const& hostname, std::string const& port
|
|||||||
|
|
||||||
if (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));
|
, me, ec, (char*)0, 0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -279,7 +279,7 @@ void http_connection::start(std::string const& hostname, std::string const& port
|
|||||||
#if TORRENT_USE_I2P
|
#if TORRENT_USE_I2P
|
||||||
if (is_i2p && i2p_conn->proxy().type != proxy_settings::i2p_proxy)
|
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));
|
, me, error_code(errors::no_i2p_router, get_libtorrent_category()), (char*)0, 0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -319,7 +319,7 @@ void http_connection::start(std::string const& hostname, std::string const& port
|
|||||||
userdata = m_ssl_ctx;
|
userdata = m_ssl_ctx;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
instantiate_connection(m_resolver.get_io_service()
|
instantiate_connection(get_io_service(m_resolver)
|
||||||
, proxy ? *proxy : null_proxy, m_sock, userdata);
|
, proxy ? *proxy : null_proxy, m_sock, userdata);
|
||||||
|
|
||||||
if (m_bind_addr != address_v4::any())
|
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);
|
m_sock.bind(tcp::endpoint(m_bind_addr, 0), ec);
|
||||||
if (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));
|
, me, ec, (char*)0, 0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -338,7 +338,7 @@ void http_connection::start(std::string const& hostname, std::string const& port
|
|||||||
setup_ssl_hostname(m_sock, hostname, ec);
|
setup_ssl_hostname(m_sock, hostname, ec);
|
||||||
if (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));
|
, me, ec, (char*)0, 0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -208,13 +208,13 @@ namespace libtorrent { namespace dht
|
|||||||
, ses.external_address().external_address(address_v4()), &ses)
|
, ses.external_address().external_address(address_v4()), &ses)
|
||||||
, m_sock(sock)
|
, m_sock(sock)
|
||||||
, m_last_new_key(time_now() - minutes(key_refresh))
|
, m_last_new_key(time_now() - minutes(key_refresh))
|
||||||
, m_timer(sock.get_io_service())
|
, m_timer(get_io_service(sock))
|
||||||
, m_connection_timer(sock.get_io_service())
|
, m_connection_timer(get_io_service(sock))
|
||||||
, m_refresh_timer(sock.get_io_service())
|
, m_refresh_timer(get_io_service(sock))
|
||||||
, m_settings(settings)
|
, m_settings(settings)
|
||||||
, m_refresh_bucket(160)
|
, m_refresh_bucket(160)
|
||||||
, m_abort(false)
|
, m_abort(false)
|
||||||
, m_host_resolver(sock.get_io_service())
|
, m_host_resolver(get_io_service(sock))
|
||||||
, m_sent_bytes(0)
|
, m_sent_bytes(0)
|
||||||
, m_received_bytes(0)
|
, m_received_bytes(0)
|
||||||
, m_refs(0)
|
, m_refs(0)
|
||||||
|
@ -90,7 +90,7 @@ void natpmp::rebind(address const& listen_interface)
|
|||||||
mutex::scoped_lock l(m_mutex);
|
mutex::scoped_lock l(m_mutex);
|
||||||
|
|
||||||
error_code ec;
|
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)
|
if (ec)
|
||||||
{
|
{
|
||||||
char msg[200];
|
char msg[200];
|
||||||
|
@ -111,7 +111,7 @@ namespace libtorrent
|
|||||||
{
|
{
|
||||||
m_last_route_update = time_now();
|
m_last_route_update = time_now();
|
||||||
error_code ec;
|
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;
|
int mtu = 0;
|
||||||
@ -220,7 +220,7 @@ namespace libtorrent
|
|||||||
{
|
{
|
||||||
m_last_route_update = time_now();
|
m_last_route_update = time_now();
|
||||||
error_code ec;
|
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;
|
if (ec) return socket_ep;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ namespace libtorrent
|
|||||||
{
|
{
|
||||||
m_last_if_update = time_now();
|
m_last_if_update = time_now();
|
||||||
error_code ec;
|
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;
|
if (ec) return socket_ep;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,14 +320,14 @@ namespace libtorrent
|
|||||||
|
|
||||||
// UTP_LOGV("not found, new connection id:%d\n", m_new_connection);
|
// UTP_LOGV("not found, new connection id:%d\n", m_new_connection);
|
||||||
|
|
||||||
boost::shared_ptr<socket_type> c(new (std::nothrow) socket_type(m_sock.get_io_service()));
|
boost::shared_ptr<socket_type> c(new (std::nothrow) socket_type(get_io_service(m_sock)));
|
||||||
if (!c) return false;
|
if (!c) return false;
|
||||||
|
|
||||||
TORRENT_ASSERT(m_new_connection == -1);
|
TORRENT_ASSERT(m_new_connection == -1);
|
||||||
// create the new socket with this ID
|
// create the new socket with this ID
|
||||||
m_new_connection = 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<utp_stream>();
|
utp_stream* str = c->get<utp_stream>();
|
||||||
TORRENT_ASSERT(str);
|
TORRENT_ASSERT(str);
|
||||||
int link_mtu, utp_mtu;
|
int link_mtu, utp_mtu;
|
||||||
|
@ -645,7 +645,11 @@ public:
|
|||||||
}
|
}
|
||||||
bool connect(const std::string& server, const std::string& port)
|
bool connect(const std::string& server, const std::string& port)
|
||||||
{
|
{
|
||||||
|
#if BOOST_VERSION >= 107000
|
||||||
|
ip::tcp::resolver resolver(static_cast<io_service&>(stream.get_executor().context()));
|
||||||
|
#else
|
||||||
ip::tcp::resolver resolver(stream.get_io_service());
|
ip::tcp::resolver resolver(stream.get_io_service());
|
||||||
|
#endif
|
||||||
ip::tcp::resolver::query query(server.c_str(), port.c_str());
|
ip::tcp::resolver::query query(server.c_str(), port.c_str());
|
||||||
ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
|
ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
|
||||||
ip::tcp::resolver::iterator end;
|
ip::tcp::resolver::iterator end;
|
||||||
@ -732,7 +736,11 @@ static void RPCListen(boost::shared_ptr< basic_socket_acceptor<Protocol> > accep
|
|||||||
const bool fUseSSL)
|
const bool fUseSSL)
|
||||||
{
|
{
|
||||||
// Accept connection
|
// Accept connection
|
||||||
|
#if BOOST_VERSION >= 107000
|
||||||
|
AcceptedConnectionImpl<Protocol>* conn = new AcceptedConnectionImpl<Protocol>(static_cast<io_service&>(acceptor->get_executor().context()), context, fUseSSL);
|
||||||
|
#else
|
||||||
AcceptedConnectionImpl<Protocol>* conn = new AcceptedConnectionImpl<Protocol>(acceptor->get_io_service(), context, fUseSSL);
|
AcceptedConnectionImpl<Protocol>* conn = new AcceptedConnectionImpl<Protocol>(acceptor->get_io_service(), context, fUseSSL);
|
||||||
|
#endif
|
||||||
|
|
||||||
acceptor->async_accept(
|
acceptor->async_accept(
|
||||||
conn->sslStream.lowest_layer(),
|
conn->sslStream.lowest_layer(),
|
||||||
|
Loading…
Reference in New Issue
Block a user