diff --git a/libtorrent/include/libtorrent/io_service_fwd.hpp b/libtorrent/include/libtorrent/io_service_fwd.hpp index 630bd5bb..3325c7e5 100644 --- a/libtorrent/include/libtorrent/io_service_fwd.hpp +++ b/libtorrent/include/libtorrent/io_service_fwd.hpp @@ -51,13 +51,17 @@ POSSIBILITY OF SUCH DAMAGE. #undef Protocol #endif + #if BOOST_VERSION >= 103500 namespace boost { #endif namespace asio { - +#if BOOST_VERSION < 106600 class io_service; - +#else +class io_context; +typedef io_context io_service; +#endif } #if BOOST_VERSION >= 103500 } diff --git a/libtorrent/include/libtorrent/proxy_base.hpp b/libtorrent/include/libtorrent/proxy_base.hpp index 47f5db49..0b0b636c 100644 --- a/libtorrent/include/libtorrent/proxy_base.hpp +++ b/libtorrent/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/libtorrent/include/libtorrent/socket_type.hpp b/libtorrent/include/libtorrent/socket_type.hpp index 602b26e2..b325b52c 100644 --- a/libtorrent/include/libtorrent/socket_type.hpp +++ b/libtorrent/include/libtorrent/socket_type.hpp @@ -272,6 +272,14 @@ namespace libtorrent 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: void destruct(); diff --git a/libtorrent/include/libtorrent/ssl_stream.hpp b/libtorrent/include/libtorrent/ssl_stream.hpp index 9cbeaef3..96a0808b 100644 --- a/libtorrent/include/libtorrent/ssl_stream.hpp +++ b/libtorrent/include/libtorrent/ssl_stream.hpp @@ -62,6 +62,11 @@ public: typedef typename Stream::endpoint_type endpoint_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) { #if OPENSSL_VERSION_NUMBER >= 0x90812f @@ -266,6 +271,13 @@ public: 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: void connected(error_code const& e, boost::shared_ptr h) diff --git a/libtorrent/include/libtorrent/utp_stream.hpp b/libtorrent/include/libtorrent/utp_stream.hpp index 923800b9..6ca4f3e7 100644 --- a/libtorrent/include/libtorrent/utp_stream.hpp +++ b/libtorrent/include/libtorrent/utp_stream.hpp @@ -177,6 +177,11 @@ public: typedef stream_socket::endpoint_type endpoint_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); ~utp_stream(); @@ -194,6 +199,12 @@ public: template 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 void bind(endpoint_type const& /*endpoint*/) {} #endif @@ -328,8 +339,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 // BOOST_VERSION { using asio::buffer_cast; using asio::buffer_size; diff --git a/libtorrent/src/file.cpp b/libtorrent/src/file.cpp index acd7704f..4bbdb8a6 100644 --- a/libtorrent/src/file.cpp +++ b/libtorrent/src/file.cpp @@ -188,7 +188,7 @@ namespace libtorrent if (_stati64(f.c_str(), &ret) < 0) #endif { - ec.assign(errno, boost::system::get_generic_category()); + ec.assign(errno, boost::system::generic_category()); return; } #else @@ -200,7 +200,7 @@ namespace libtorrent retval = ::stat(f.c_str(), &ret); if (retval < 0) { - ec.assign(errno, boost::system::get_generic_category()); + ec.assign(errno, boost::system::generic_category()); return; } #endif // TORRENT_WINDOWS @@ -239,7 +239,7 @@ namespace libtorrent if (::rename(f1.c_str(), f2.c_str()) < 0) #endif { - ec.assign(errno, boost::system::get_generic_category()); + ec.assign(errno, boost::system::generic_category()); return; } } @@ -279,7 +279,7 @@ namespace libtorrent #else int ret = mkdir(n.c_str(), 0777); if (ret < 0 && errno != EEXIST) - ec.assign(errno, boost::system::get_generic_category()); + ec.assign(errno, boost::system::generic_category()); #endif } @@ -335,13 +335,13 @@ namespace libtorrent // this only works on 10.5 copyfile_state_t state = copyfile_state_alloc(); 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); #else int infd = ::open(inf.c_str(), O_RDONLY); if (infd < 0) { - ec.assign(errno, boost::system::get_generic_category()); + ec.assign(errno, boost::system::generic_category()); return; } @@ -355,7 +355,7 @@ namespace libtorrent if (outfd < 0) { close(infd); - ec.assign(errno, boost::system::get_generic_category()); + ec.assign(errno, boost::system::generic_category()); return; } char buffer[4096]; @@ -365,13 +365,13 @@ namespace libtorrent if (num_read == 0) break; if (num_read < 0) { - ec.assign(errno, boost::system::get_generic_category()); + ec.assign(errno, boost::system::generic_category()); break; } int num_written = write(outfd, buffer, num_read); if (num_written < num_read) { - ec.assign(errno, boost::system::get_generic_category()); + ec.assign(errno, boost::system::generic_category()); break; } if (num_read < int(sizeof(buffer))) break; @@ -699,7 +699,7 @@ namespace libtorrent std::string f = convert_to_native(inf); if (::remove(f.c_str()) < 0) { - ec.assign(errno, boost::system::get_generic_category()); + ec.assign(errno, boost::system::generic_category()); return; } #endif // TORRENT_WINDOWS @@ -792,7 +792,7 @@ namespace libtorrent m_handle = opendir(p.c_str()); if (m_handle == 0) { - ec.assign(errno, boost::system::get_generic_category()); + ec.assign(errno, boost::system::generic_category()); m_done = true; return; } @@ -844,7 +844,7 @@ namespace libtorrent dirent* dummy; 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; } if (dummy == 0) m_done = true; diff --git a/libtorrent/src/http_connection.cpp b/libtorrent/src/http_connection.cpp index d420074a..28595506 100644 --- a/libtorrent/src/http_connection.cpp +++ b/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) { - m_ssl_ctx = new (std::nothrow) boost::asio::ssl::context( - m_resolver.get_io_service(), asio::ssl::context::sslv23_client); + m_ssl_ctx = new (std::nothrow) boost::asio::ssl::context(asio::ssl::context::sslv23_client); if (m_ssl_ctx) { m_own_ssl_context = true; diff --git a/libtorrent/src/peer_connection.cpp b/libtorrent/src/peer_connection.cpp index 1bcaa40f..a7881f50 100644 --- a/libtorrent/src/peer_connection.cpp +++ b/libtorrent/src/peer_connection.cpp @@ -465,9 +465,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); @@ -5706,11 +5705,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); #if defined TORRENT_VERBOSE_LOGGING peer_log("*** SET NON-BLOCKING"); #endif - m_socket->io_control(ioc, ec); + m_socket->non_blocking(true, ec); if (ec) { disconnect(ec); diff --git a/libtorrent/src/session_impl.cpp b/libtorrent/src/session_impl.cpp index 3efd5c43..3412243b 100644 --- a/libtorrent/src/session_impl.cpp +++ b/libtorrent/src/session_impl.cpp @@ -614,7 +614,7 @@ namespace aux { , m_swarmDb(swarmDb) , m_io_service() #ifdef TORRENT_USE_OPENSSL - , m_ssl_ctx(m_io_service, asio::ssl::context::sslv23) + , m_ssl_ctx(asio::ssl::context::sslv23) #endif , 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) diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index 368c44d6..458845a8 100644 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -1405,7 +1405,7 @@ namespace libtorrent // inject the root certificate, and no other, to // verify other peers against boost::shared_ptr ctx( - new (std::nothrow) context(m_ses.m_io_service, context::sslv23)); + new (std::nothrow) context(context::sslv23)); if (!ctx) { @@ -1442,7 +1442,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/libtorrent/src/udp_socket.cpp b/libtorrent/src/udp_socket.cpp index cf18b7f5..7adf6115 100644 --- a/libtorrent/src/udp_socket.cpp +++ b/libtorrent/src/udp_socket.cpp @@ -700,8 +700,7 @@ void udp_socket::bind(udp::endpoint const& ep, error_code& ec) if (ec) return; 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); } @@ -714,8 +713,7 @@ void udp_socket::bind(udp::endpoint const& ep, error_code& ec) #endif m_ipv6_sock.bind(ep, ec); 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); } diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 317fab3a..d371faef 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -691,8 +691,8 @@ private: void ServiceConnection(AcceptedConnection *conn); // Forward declaration required for RPCListen -template -static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor > acceptor, +template +static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor > acceptor, ssl::context& context, bool fUseSSL, AcceptedConnection* conn, @@ -701,8 +701,8 @@ static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor -static void RPCListen(boost::shared_ptr< basic_socket_acceptor > acceptor, +template +static void RPCListen(boost::shared_ptr< basic_socket_acceptor > acceptor, ssl::context& context, const bool fUseSSL) { @@ -712,7 +712,7 @@ static void RPCListen(boost::shared_ptr< basic_socket_acceptorasync_accept( conn->sslStream.lowest_layer(), conn->peer, - boost::bind(&RPCAcceptHandler, + boost::bind(&RPCAcceptHandler, acceptor, boost::ref(context), fUseSSL, @@ -723,8 +723,8 @@ static void RPCListen(boost::shared_ptr< basic_socket_acceptor -static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor > acceptor, +template +static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor > acceptor, ssl::context& context, const bool fUseSSL, AcceptedConnection* conn, @@ -794,7 +794,7 @@ void StartRPCThreads() assert(rpc_io_service == NULL); 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); @@ -813,7 +813,7 @@ void StartRPCThreads() 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"); - 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 @@ -1187,7 +1187,7 @@ Object CallRPC(const string& strMethod, const Array& params) // Connect to localhost bool fUseSSL = GetBoolArg("-rpcssl", false); 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); asio::ssl::stream sslStream(io_service, context); SSLIOStreamDevice d(sslStream, fUseSSL);