Skip to content

Fix for boost 1.70 (get_io_service() was deprecated and was removed) #878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix for boost 1.70 (get_io_service() was deprecated and was removed)
  • Loading branch information
enricodetoma committed Aug 8, 2019
commit 5351fc6e2cf26a205e9a0eb029d96f689bc43b78
10 changes: 9 additions & 1 deletion boost/network/protocol/http/client/connection/async_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
#include <boost/network/protocol/http/traits/resolver_policy.hpp>
#include <boost/network/traits/string.hpp>

#ifndef GET_IO_SERVICE
#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
#endif

namespace boost {
namespace network {
namespace http {
Expand Down Expand Up @@ -59,7 +67,7 @@ struct async_connection_base {
async_connection;
typedef typename delegate_factory<Tag>::type delegate_factory_type;
auto delegate = delegate_factory_type::new_connection_delegate(
(boost::asio::io_context &)resolver.get_executor().context(), https, always_verify_peer,
GET_IO_SERVICE(resolver), https, always_verify_peer,
certificate_filename, verify_path, certificate_file, private_key_file,
ciphers, sni_hostname, ssl_options);
auto temp = std::make_shared<async_connection>(
Expand Down
12 changes: 10 additions & 2 deletions boost/network/protocol/http/client/connection/async_normal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
#include <boost/range/iterator_range.hpp>
#include <boost/throw_exception.hpp>

#ifndef GET_IO_SERVICE
#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
#endif

namespace boost {
namespace network {
namespace http {
Expand Down Expand Up @@ -154,12 +162,12 @@ struct http_async_connection
connection_delegate_ptr delegate)
: timeout_(timeout),
remove_chunk_markers_(remove_chunk_markers),
timer_((boost::asio::io_context &)resolver.get_executor().context()),
timer_(GET_IO_SERVICE(resolver)),
is_timedout_(false),
follow_redirect_(follow_redirect),
resolver_(resolver),
resolve_(std::move(resolve)),
request_strand_((boost::asio::io_context &)resolver.get_executor().context()),
request_strand_(GET_IO_SERVICE(resolver)),
delegate_(std::move(delegate)) {}

// This is the main entry point for the connection/request pipeline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ struct connection_delegate_factory {
// This is the factory method that actually returns the delegate instance.
// TODO(dberris): Support passing in proxy settings when crafting connections.
static connection_delegate_ptr new_connection_delegate(
boost::asio::io_context& service, bool https, bool always_verify_peer,
#if BOOST_VERSION >= 107000
boost::asio::io_context& service,
#else
boost::asio::io_service& service,
#endif
bool https, bool always_verify_peer,
optional<string_type> certificate_filename,
optional<string_type> verify_path, optional<string_type> certificate_file,
optional<string_type> private_key_file, optional<string_type> ciphers,
Expand Down
12 changes: 10 additions & 2 deletions boost/network/protocol/http/client/connection/sync_normal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
#include <boost/network/protocol/http/traits/resolver_policy.hpp>
#include <boost/network/traits/string.hpp>

#ifndef GET_IO_SERVICE
#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
#endif

namespace boost {
namespace network {
namespace http {
Expand Down Expand Up @@ -49,10 +57,10 @@ struct http_sync_connection
int timeout)
: connection_base(),
timeout_(timeout),
timer_((boost::asio::io_context &)resolver.get_executor().context()),
timer_(GET_IO_SERVICE(resolver)),
resolver_(resolver),
resolve_(std::move(resolve)),
socket_((boost::asio::io_context &)resolver.get_executor().context()) {}
socket_(GET_IO_SERVICE(resolver)) {}

void init_socket(string_type const& hostname, string_type const& port) {
connection_base::init_socket(socket_, resolver_, hostname, port, resolve_);
Expand Down
14 changes: 11 additions & 3 deletions boost/network/protocol/http/client/connection/sync_ssl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
#include <boost/network/protocol/http/request.hpp>
#include <boost/network/protocol/http/traits/resolver_policy.hpp>

#ifndef GET_IO_SERVICE
#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
#endif

namespace boost {
namespace network {
namespace http {
Expand Down Expand Up @@ -60,11 +68,11 @@ struct https_sync_connection
long ssl_options = 0)
: connection_base(),
timeout_(timeout),
timer_((boost::asio::io_context &)resolver.get_executor().context()),
timer_(GET_IO_SERVICE(resolver)),
resolver_(resolver),
resolve_(std::move(resolve)),
context_((boost::asio::io_context &)resolver.get_executor().context(), boost::asio::ssl::context::sslv23_client),
socket_((boost::asio::io_context &)resolver.get_executor().context(), context_) {
context_(GET_IO_SERVICE(resolver), boost::asio::ssl::context::sslv23_client),
socket_(GET_IO_SERVICE(resolver), context_) {
if (ciphers) {
::SSL_CTX_set_cipher_list(context_.native_handle(), ciphers->c_str());
}
Expand Down