Skip to content

Commit

Permalink
asio: support boost-1.70
Browse files Browse the repository at this point in the history
In boost 1.70, deprecated get_io_context() has finally been removed.
Introduce GET_IO_SERVICE macro that based on boost version uses
old get_io_service() interface (boost < 1.70), or get_executor().context()
for boost 1.70+.

Commit based idea seen in monero-project/monero@17769db
  • Loading branch information
adamgolebiowski committed Apr 18, 2019
1 parent e86d137 commit cbba1eb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/asio_server_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
#include "util.h"
#include "template.h"

#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

namespace nghttp2 {

namespace asio_http2 {
Expand All @@ -71,7 +77,7 @@ class connection : public std::enable_shared_from_this<connection<socket_type>>,
SocketArgs &&... args)
: socket_(std::forward<SocketArgs>(args)...),
mux_(mux),
deadline_(socket_.get_io_service()),
deadline_(GET_IO_SERVICE(socket_)),
tls_handshake_timeout_(tls_handshake_timeout),
read_timeout_(read_timeout),
writing_(false),
Expand All @@ -82,7 +88,7 @@ class connection : public std::enable_shared_from_this<connection<socket_type>>,
boost::system::error_code ec;

handler_ = std::make_shared<http2_handler>(
socket_.get_io_service(), socket_.lowest_layer().remote_endpoint(ec),
GET_IO_SERVICE(socket_), socket_.lowest_layer().remote_endpoint(ec),
[this]() { do_write(); }, mux_);
if (handler_->start() != 0) {
stop();
Expand Down

0 comments on commit cbba1eb

Please sign in to comment.