Browse Source

boost 1.66 patch...

miguelfreitas
erqan 7 years ago
parent
commit
575e929d29
  1. 8
      libtorrent/include/libtorrent/io_service_fwd.hpp
  2. 17
      libtorrent/include/libtorrent/proxy_base.hpp
  3. 8
      libtorrent/include/libtorrent/socket_type.hpp
  4. 12
      libtorrent/include/libtorrent/ssl_stream.hpp
  5. 16
      libtorrent/include/libtorrent/utp_stream.hpp
  6. 24
      libtorrent/src/file.cpp
  7. 3
      libtorrent/src/http_connection.cpp
  8. 6
      libtorrent/src/peer_connection.cpp
  9. 2
      libtorrent/src/session_impl.cpp
  10. 4
      libtorrent/src/torrent.cpp
  11. 6
      libtorrent/src/udp_socket.cpp
  12. 20
      src/bitcoinrpc.cpp

8
libtorrent/include/libtorrent/io_service_fwd.hpp

@ -51,13 +51,17 @@ POSSIBILITY OF SUCH DAMAGE.
#undef Protocol #undef Protocol
#endif #endif
#if BOOST_VERSION >= 103500 #if BOOST_VERSION >= 103500
namespace boost { namespace boost {
#endif #endif
namespace asio { namespace asio {
#if BOOST_VERSION < 106600
class io_service; class io_service;
#else
class io_context;
typedef io_context io_service;
#endif
} }
#if BOOST_VERSION >= 103500 #if BOOST_VERSION >= 103500
} }

17
libtorrent/include/libtorrent/proxy_base.hpp

@ -63,6 +63,11 @@ public:
m_port = port; 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> template <class Mutable_Buffers, class Handler>
void async_read_some(Mutable_Buffers const& buffers, Handler const& handler) void async_read_some(Mutable_Buffers const& buffers, Handler const& handler)
{ {
@ -119,6 +124,18 @@ public:
m_sock.async_write_some(buffers, handler); 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 #ifndef BOOST_NO_EXCEPTIONS
template <class SettableSocketOption> template <class SettableSocketOption>
void set_option(SettableSocketOption const& opt) void set_option(SettableSocketOption const& opt)

8
libtorrent/include/libtorrent/socket_type.hpp

@ -272,6 +272,14 @@ namespace libtorrent
return (S const*)m_data; return (S const*)m_data;
} }
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
private: private:
void destruct(); void destruct();

12
libtorrent/include/libtorrent/ssl_stream.hpp

@ -62,6 +62,11 @@ public:
typedef typename Stream::endpoint_type endpoint_type; typedef typename Stream::endpoint_type endpoint_type;
typedef typename Stream::protocol_type protocol_type; typedef typename Stream::protocol_type protocol_type;
#if BOOST_VERSION >= 106600
typedef tcp::socket::executor_type executor_type;
executor_type get_executor() { return m_sock.get_executor(); }
#endif
void set_host_name(std::string name) void set_host_name(std::string name)
{ {
#if OPENSSL_VERSION_NUMBER >= 0x90812f #if OPENSSL_VERSION_NUMBER >= 0x90812f
@ -266,6 +271,13 @@ public:
return m_sock.next_layer(); return m_sock.next_layer();
} }
#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); }
private: private:
void connected(error_code const& e, boost::shared_ptr<handler_type> h) void connected(error_code const& e, boost::shared_ptr<handler_type> h)

16
libtorrent/include/libtorrent/utp_stream.hpp

@ -177,6 +177,11 @@ public:
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;
executor_type get_executor() { return m_io_service.get_executor(); }
#endif
explicit utp_stream(asio::io_service& io_service); explicit utp_stream(asio::io_service& io_service);
~utp_stream(); ~utp_stream();
@ -194,6 +199,12 @@ public:
template <class IO_Control_Command> template <class IO_Control_Command>
void io_control(IO_Control_Command& ioc, error_code& ec) {} void io_control(IO_Control_Command& ioc, error_code& ec) {}
#ifndef BOOST_NO_EXCEPTIONS
void non_blocking(bool) {}
#endif
error_code non_blocking(bool, error_code&) { return error_code(); }
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
void bind(endpoint_type const& /*endpoint*/) {} void bind(endpoint_type const& /*endpoint*/) {}
#endif #endif
@ -328,8 +339,13 @@ public:
size_t buf_size = 0; size_t buf_size = 0;
#endif #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() for (typename Mutable_Buffers::const_iterator i = buffers.begin()
, end(buffers.end()); i != end; ++i) , end(buffers.end()); i != end; ++i)
#endif // BOOST_VERSION
{ {
using asio::buffer_cast; using asio::buffer_cast;
using asio::buffer_size; using asio::buffer_size;

24
libtorrent/src/file.cpp

@ -188,7 +188,7 @@ namespace libtorrent
if (_stati64(f.c_str(), &ret) < 0) if (_stati64(f.c_str(), &ret) < 0)
#endif #endif
{ {
ec.assign(errno, boost::system::get_generic_category()); ec.assign(errno, boost::system::generic_category());
return; return;
} }
#else #else
@ -200,7 +200,7 @@ namespace libtorrent
retval = ::stat(f.c_str(), &ret); retval = ::stat(f.c_str(), &ret);
if (retval < 0) if (retval < 0)
{ {
ec.assign(errno, boost::system::get_generic_category()); ec.assign(errno, boost::system::generic_category());
return; return;
} }
#endif // TORRENT_WINDOWS #endif // TORRENT_WINDOWS
@ -239,7 +239,7 @@ namespace libtorrent
if (::rename(f1.c_str(), f2.c_str()) < 0) if (::rename(f1.c_str(), f2.c_str()) < 0)
#endif #endif
{ {
ec.assign(errno, boost::system::get_generic_category()); ec.assign(errno, boost::system::generic_category());
return; return;
} }
} }
@ -279,7 +279,7 @@ namespace libtorrent
#else #else
int ret = mkdir(n.c_str(), 0777); int ret = mkdir(n.c_str(), 0777);
if (ret < 0 && errno != EEXIST) if (ret < 0 && errno != EEXIST)
ec.assign(errno, boost::system::get_generic_category()); ec.assign(errno, boost::system::generic_category());
#endif #endif
} }
@ -335,13 +335,13 @@ namespace libtorrent
// this only works on 10.5 // this only works on 10.5
copyfile_state_t state = copyfile_state_alloc(); copyfile_state_t state = copyfile_state_alloc();
if (copyfile(f1.c_str(), f2.c_str(), state, COPYFILE_ALL) < 0) if (copyfile(f1.c_str(), f2.c_str(), state, COPYFILE_ALL) < 0)
ec.assign(errno, boost::system::get_generic_category()); ec.assign(errno, boost::system::generic_category());
copyfile_state_free(state); copyfile_state_free(state);
#else #else
int infd = ::open(inf.c_str(), O_RDONLY); int infd = ::open(inf.c_str(), O_RDONLY);
if (infd < 0) if (infd < 0)
{ {
ec.assign(errno, boost::system::get_generic_category()); ec.assign(errno, boost::system::generic_category());
return; return;
} }
@ -355,7 +355,7 @@ namespace libtorrent
if (outfd < 0) if (outfd < 0)
{ {
close(infd); close(infd);
ec.assign(errno, boost::system::get_generic_category()); ec.assign(errno, boost::system::generic_category());
return; return;
} }
char buffer[4096]; char buffer[4096];
@ -365,13 +365,13 @@ namespace libtorrent
if (num_read == 0) break; if (num_read == 0) break;
if (num_read < 0) if (num_read < 0)
{ {
ec.assign(errno, boost::system::get_generic_category()); ec.assign(errno, boost::system::generic_category());
break; break;
} }
int num_written = write(outfd, buffer, num_read); int num_written = write(outfd, buffer, num_read);
if (num_written < num_read) if (num_written < num_read)
{ {
ec.assign(errno, boost::system::get_generic_category()); ec.assign(errno, boost::system::generic_category());
break; break;
} }
if (num_read < int(sizeof(buffer))) break; if (num_read < int(sizeof(buffer))) break;
@ -699,7 +699,7 @@ namespace libtorrent
std::string f = convert_to_native(inf); std::string f = convert_to_native(inf);
if (::remove(f.c_str()) < 0) if (::remove(f.c_str()) < 0)
{ {
ec.assign(errno, boost::system::get_generic_category()); ec.assign(errno, boost::system::generic_category());
return; return;
} }
#endif // TORRENT_WINDOWS #endif // TORRENT_WINDOWS
@ -792,7 +792,7 @@ namespace libtorrent
m_handle = opendir(p.c_str()); m_handle = opendir(p.c_str());
if (m_handle == 0) if (m_handle == 0)
{ {
ec.assign(errno, boost::system::get_generic_category()); ec.assign(errno, boost::system::generic_category());
m_done = true; m_done = true;
return; return;
} }
@ -844,7 +844,7 @@ namespace libtorrent
dirent* dummy; dirent* dummy;
if (readdir_r(m_handle, &m_dirent, &dummy) != 0) if (readdir_r(m_handle, &m_dirent, &dummy) != 0)
{ {
ec.assign(errno, boost::system::get_generic_category()); ec.assign(errno, boost::system::generic_category());
m_done = true; m_done = true;
} }
if (dummy == 0) m_done = true; if (dummy == 0) m_done = true;

3
libtorrent/src/http_connection.cpp

@ -307,8 +307,7 @@ void http_connection::start(std::string const& hostname, std::string const& port
{ {
if (m_ssl_ctx == 0) if (m_ssl_ctx == 0)
{ {
m_ssl_ctx = new (std::nothrow) boost::asio::ssl::context( m_ssl_ctx = new (std::nothrow) boost::asio::ssl::context(asio::ssl::context::sslv23_client);
m_resolver.get_io_service(), asio::ssl::context::sslv23_client);
if (m_ssl_ctx) if (m_ssl_ctx)
{ {
m_own_ssl_context = true; m_own_ssl_context = true;

6
libtorrent/src/peer_connection.cpp

@ -465,9 +465,8 @@ namespace libtorrent
if (!m_outgoing) if (!m_outgoing)
{ {
tcp::socket::non_blocking_io ioc(true);
error_code ec; error_code ec;
m_socket->io_control(ioc, ec); m_socket->non_blocking(true, ec);
if (ec) if (ec)
{ {
disconnect(ec); disconnect(ec);
@ -5706,11 +5705,10 @@ namespace libtorrent
// set the socket to non-blocking, so that we can // set the socket to non-blocking, so that we can
// read the entire buffer on each read event we get // read the entire buffer on each read event we get
tcp::socket::non_blocking_io ioc(true);
#if defined TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING
peer_log("*** SET NON-BLOCKING"); peer_log("*** SET NON-BLOCKING");
#endif #endif
m_socket->io_control(ioc, ec); m_socket->non_blocking(true, ec);
if (ec) if (ec)
{ {
disconnect(ec); disconnect(ec);

2
libtorrent/src/session_impl.cpp

@ -614,7 +614,7 @@ namespace aux {
, m_swarmDb(swarmDb) , m_swarmDb(swarmDb)
, m_io_service() , m_io_service()
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
, m_ssl_ctx(m_io_service, asio::ssl::context::sslv23) , m_ssl_ctx(asio::ssl::context::sslv23)
#endif #endif
, m_alerts(m_settings.alert_queue_size, alert_mask) , m_alerts(m_settings.alert_queue_size, alert_mask)
, m_disk_thread(m_io_service, boost::bind(&session_impl::on_disk_queue, this), m_files) , m_disk_thread(m_io_service, boost::bind(&session_impl::on_disk_queue, this), m_files)

4
libtorrent/src/torrent.cpp

@ -1405,7 +1405,7 @@ namespace libtorrent
// inject the root certificate, and no other, to // inject the root certificate, and no other, to
// verify other peers against // verify other peers against
boost::shared_ptr<context> ctx( boost::shared_ptr<context> ctx(
new (std::nothrow) context(m_ses.m_io_service, context::sslv23)); new (std::nothrow) context(context::sslv23));
if (!ctx) if (!ctx)
{ {
@ -1442,7 +1442,7 @@ namespace libtorrent
return; return;
} }
SSL_CTX* ssl_ctx = ctx->impl(); SSL_CTX* ssl_ctx = ctx->native_handle();
// create a new x.509 certificate store // create a new x.509 certificate store
X509_STORE* cert_store = X509_STORE_new(); X509_STORE* cert_store = X509_STORE_new();
if (!cert_store) if (!cert_store)

6
libtorrent/src/udp_socket.cpp

@ -700,8 +700,7 @@ void udp_socket::bind(udp::endpoint const& ep, error_code& ec)
if (ec) return; if (ec) return;
m_ipv4_sock.bind(ep, ec); m_ipv4_sock.bind(ep, ec);
if (ec) return; if (ec) return;
udp::socket::non_blocking_io ioc(true); m_ipv4_sock.non_blocking(true, ec);
m_ipv4_sock.io_control(ioc, ec);
if (ec) return; if (ec) return;
setup_read(&m_ipv4_sock); setup_read(&m_ipv4_sock);
} }
@ -714,8 +713,7 @@ void udp_socket::bind(udp::endpoint const& ep, error_code& ec)
#endif #endif
m_ipv6_sock.bind(ep, ec); m_ipv6_sock.bind(ep, ec);
if (ec) return; if (ec) return;
udp::socket::non_blocking_io ioc(true); m_ipv6_sock.non_blocking(true, ec);
m_ipv6_sock.io_control(ioc, ec);
if (ec) return; if (ec) return;
setup_read(&m_ipv6_sock); setup_read(&m_ipv6_sock);
} }

20
src/bitcoinrpc.cpp

@ -691,8 +691,8 @@ private:
void ServiceConnection(AcceptedConnection *conn); void ServiceConnection(AcceptedConnection *conn);
// Forward declaration required for RPCListen // Forward declaration required for RPCListen
template <typename Protocol, typename SocketAcceptorService> template <typename Protocol>
static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol, SocketAcceptorService> > acceptor, static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol> > acceptor,
ssl::context& context, ssl::context& context,
bool fUseSSL, bool fUseSSL,
AcceptedConnection* conn, AcceptedConnection* conn,
@ -701,8 +701,8 @@ static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol,
/** /**
* Sets up I/O resources to accept and handle a new connection. * Sets up I/O resources to accept and handle a new connection.
*/ */
template <typename Protocol, typename SocketAcceptorService> template <typename Protocol>
static void RPCListen(boost::shared_ptr< basic_socket_acceptor<Protocol, SocketAcceptorService> > acceptor, static void RPCListen(boost::shared_ptr< basic_socket_acceptor<Protocol> > acceptor,
ssl::context& context, ssl::context& context,
const bool fUseSSL) const bool fUseSSL)
{ {
@ -712,7 +712,7 @@ static void RPCListen(boost::shared_ptr< basic_socket_acceptor<Protocol, SocketA
acceptor->async_accept( acceptor->async_accept(
conn->sslStream.lowest_layer(), conn->sslStream.lowest_layer(),
conn->peer, conn->peer,
boost::bind(&RPCAcceptHandler<Protocol, SocketAcceptorService>, boost::bind(&RPCAcceptHandler<Protocol>,
acceptor, acceptor,
boost::ref(context), boost::ref(context),
fUseSSL, fUseSSL,
@ -723,8 +723,8 @@ static void RPCListen(boost::shared_ptr< basic_socket_acceptor<Protocol, SocketA
/** /**
* Accept and handle incoming connection. * Accept and handle incoming connection.
*/ */
template <typename Protocol, typename SocketAcceptorService> template <typename Protocol>
static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol, SocketAcceptorService> > acceptor, static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol> > acceptor,
ssl::context& context, ssl::context& context,
const bool fUseSSL, const bool fUseSSL,
AcceptedConnection* conn, AcceptedConnection* conn,
@ -794,7 +794,7 @@ void StartRPCThreads()
assert(rpc_io_service == NULL); assert(rpc_io_service == NULL);
rpc_io_service = new asio::io_service(); rpc_io_service = new asio::io_service();
rpc_ssl_context = new ssl::context(*rpc_io_service, ssl::context::sslv23); rpc_ssl_context = new ssl::context(ssl::context::sslv23);
const bool fUseSSL = GetBoolArg("-rpcssl", false); const bool fUseSSL = GetBoolArg("-rpcssl", false);
@ -813,7 +813,7 @@ void StartRPCThreads()
else printf("ThreadRPCServer ERROR: missing server private key file %s\n", pathPKFile.string().c_str()); else printf("ThreadRPCServer ERROR: missing server private key file %s\n", pathPKFile.string().c_str());
string strCiphers = GetArg("-rpcsslciphers", "TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH"); string strCiphers = GetArg("-rpcsslciphers", "TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH");
SSL_CTX_set_cipher_list(rpc_ssl_context->impl(), strCiphers.c_str()); SSL_CTX_set_cipher_list(rpc_ssl_context->native_handle(), strCiphers.c_str());
} }
// Try a dual IPv6/IPv4 socket, falling back to separate IPv4 and IPv6 sockets // Try a dual IPv6/IPv4 socket, falling back to separate IPv4 and IPv6 sockets
@ -1187,7 +1187,7 @@ Object CallRPC(const string& strMethod, const Array& params)
// Connect to localhost // Connect to localhost
bool fUseSSL = GetBoolArg("-rpcssl", false); bool fUseSSL = GetBoolArg("-rpcssl", false);
asio::io_service io_service; asio::io_service io_service;
ssl::context context(io_service, ssl::context::sslv23); ssl::context context(ssl::context::sslv23);
context.set_options(ssl::context::no_sslv2); context.set_options(ssl::context::no_sslv2);
asio::ssl::stream<asio::ip::tcp::socket> sslStream(io_service, context); asio::ssl::stream<asio::ip::tcp::socket> sslStream(io_service, context);
SSLIOStreamDevice<asio::ip::tcp> d(sslStream, fUseSSL); SSLIOStreamDevice<asio::ip::tcp> d(sslStream, fUseSSL);

Loading…
Cancel
Save