Skip to content
This repository was archived by the owner on Jul 23, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/rpcclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<asio::ip::tcp::socket> sslStream(io_service, context);
asio::ssl::stream<asio::ip::tcp::socket> sslStream(io_context, context);
SSLIOStreamDevice<asio::ip::tcp> d(sslStream, fUseSSL);
iostreams::stream< SSLIOStreamDevice<asio::ip::tcp> > stream(d);

Expand Down
27 changes: 21 additions & 6 deletions src/rpcprotocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -114,9 +127,11 @@ class SSLIOStreamDevice : public boost::iostreams::device<boost::iostreams::bidi
}
bool connect(const std::string& server, const std::string& port)
{
// Boost Version < 1.70 handling - Thank you Mino#8171
// Boost Version < 1.70 handling (Updated) - Thank you https://github.com/g1itch
boost::asio::ip::tcp::resolver resolver(GetIOService(stream));
// Boost Version < 1.70 handling (Depricated) - Thank you Mino#8171
// boost::asio::ip::tcp::resolver resolver(stream.get_io_service());
boost::asio::ip::tcp::resolver resolver(GET_IO_SERVICE(stream));
// boost::asio::ip::tcp::resolver resolver(GET_IO_SERVICE(stream));
boost::asio::ip::tcp::resolver::query query(server.c_str(), port.c_str());
boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
boost::asio::ip::tcp::resolver::iterator end;
Expand Down
16 changes: 10 additions & 6 deletions src/rpcserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ using namespace json_spirit;
static std::string strRPCUserColonPass;

// These are created by StartRPCThreads, destroyed in StopRPCThreads
static asio::io_service* rpc_io_service = NULL;
static ioContext* rpc_io_service = NULL;
static map<string, boost::shared_ptr<deadline_timer> > deadlineTimers;
static ssl::context* rpc_ssl_context = NULL;
static boost::thread_group* rpc_worker_group = NULL;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -477,8 +477,12 @@ static void RPCListen(boost::shared_ptr< basic_socket_acceptor<Protocol> > 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<Protocol>* conn = new AcceptedConnectionImpl<Protocol>(acceptor->get_io_service(), context, fUseSSL);
AcceptedConnectionImpl<Protocol>* conn = new AcceptedConnectionImpl<Protocol>(GET_IO_SERVICE(acceptor), context, fUseSSL);
// AcceptedConnectionImpl<Protocol>* conn = new AcceptedConnectionImpl<Protocol>(GET_IO_SERVICE(acceptor), context, fUseSSL);
AcceptedConnectionImpl<Protocol>* conn = new AcceptedConnectionImpl<Protocol>(GetIOServiceFromPtr(acceptor), context, fUseSSL);
acceptor->async_accept(
conn->sslStream.lowest_layer(),
conn->peer,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand Down