diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index b8f2e42f..81f82257 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -40,10 +40,10 @@ Object CallRPC(const string& strMethod, const Array& params) // Connect to localhost bool fUseSSL = GetBoolArg("-rpcssl", false); - asio::io_service io_service; + ioContext io_context; ssl::context context(ssl::context::sslv23); context.set_options(ssl::context::no_sslv2); - asio::ssl::stream sslStream(io_service, context); + asio::ssl::stream sslStream(io_context, context); SSLIOStreamDevice d(sslStream, fUseSSL); iostreams::stream< SSLIOStreamDevice > stream(d); diff --git a/src/rpcprotocol.h b/src/rpcprotocol.h index 7d0ae5c5..ed24a158 100644 --- a/src/rpcprotocol.h +++ b/src/rpcprotocol.h @@ -22,13 +22,26 @@ #include "json/json_spirit_utils.h" #include "json/json_spirit_writer_template.h" -// ====== BOOST SUCKS ======== - +// Boost Support for 1.70+ (Updated) +// Thank you https://github.com/g1itch #if BOOST_VERSION >= 107000 -#define GET_IO_SERVICE(s) ((boost::asio::io_context&)(s).get_executor().context()) + #define GetIOService(s) ((boost::asio::io_context&)(s).get_executor().context()) + #define GetIOServiceFromPtr(s) ((boost::asio::io_context&)(s->get_executor().context())) // this one + typedef boost::asio::io_context ioContext; + #else -#define GET_IO_SERVICE(s) ((s).get_io_service()) + #define GetIOService(s) ((s).get_io_service()) + #define GetIOServiceFromPtr(s) ((s)->get_io_service()) + typedef boost::asio::io_service ioContext; #endif +// Boost Support for 1.70+ (Depricated) +// Thank you Mino#8171 +// ====== BOOST SUCKS ======== +// #if BOOST_VERSION >= 107000 +// #define GET_IO_SERVICE(s) ((boost::asio::io_context&)(s).get_executor().context()) +// #else +// #define GET_IO_SERVICE(s) ((s).get_io_service()) +// #endif // ===== RETROCOMPATIBILITY SHOULD NOT BE AN OPTION ====== // HTTP status codes @@ -114,9 +127,11 @@ class SSLIOStreamDevice : public boost::iostreams::device > deadlineTimers; static ssl::context* rpc_ssl_context = NULL; static boost::thread_group* rpc_worker_group = NULL; @@ -424,10 +424,10 @@ class AcceptedConnectionImpl : public AcceptedConnection { public: AcceptedConnectionImpl( - asio::io_service& io_service, + ioContext& io_context, ssl::context &context, bool fUseSSL) : - sslStream(io_service, context), + sslStream(io_context, context), _d(sslStream, fUseSSL), _stream(_d) { @@ -477,8 +477,12 @@ static void RPCListen(boost::shared_ptr< basic_socket_acceptor > accep // Accept connection // // Boost Version < 1.70 handling - Thank you Mino#8171 + // Boost 1.70+ update patch by https://github.com/g1itch + // (This improves upon Mino's 1.70 support update) + // // AcceptedConnectionImpl* conn = new AcceptedConnectionImpl(acceptor->get_io_service(), context, fUseSSL); -AcceptedConnectionImpl* conn = new AcceptedConnectionImpl(GET_IO_SERVICE(acceptor), context, fUseSSL); + // AcceptedConnectionImpl* conn = new AcceptedConnectionImpl(GET_IO_SERVICE(acceptor), context, fUseSSL); + AcceptedConnectionImpl* conn = new AcceptedConnectionImpl(GetIOServiceFromPtr(acceptor), context, fUseSSL); acceptor->async_accept( conn->sslStream.lowest_layer(), conn->peer, @@ -563,7 +567,7 @@ void StartRPCThreads() } assert(rpc_io_service == NULL); - rpc_io_service = new asio::io_service(); + rpc_io_service = new ioContext(); rpc_ssl_context = new ssl::context(ssl::context::sslv23); const bool fUseSSL = GetBoolArg("-rpcssl", false); @@ -646,7 +650,7 @@ void StartRPCThreads() rpc_worker_group = new boost::thread_group(); for (int i = 0; i < GetArg("-rpcthreads", 4); i++) - rpc_worker_group->create_thread(boost::bind(&asio::io_service::run, rpc_io_service)); + rpc_worker_group->create_thread(boost::bind(&ioContext::run, rpc_io_service)); } void StopRPCThreads()