Skip to content

Commit

Permalink
Merge pull request #67 from rcane/feature/boost_1_72_0_support
Browse files Browse the repository at this point in the history
Fixed the build with asio-1.16 (boost-1.72.0).
  • Loading branch information
eao197 committed Jan 27, 2020
2 parents d634fa9 + ee42bce commit 003b199
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions dev/restinio/asio_include.hpp
Expand Up @@ -13,6 +13,9 @@
// RESTinio uses stand-alone version of asio.
#include <asio.hpp>

// Define added to not have to distinguish between boost and non-boost asio in other code.
#define RESTINIO_ASIO_VERSION ASIO_VERSION

namespace restinio
{
namespace asio_ns = ::asio;
Expand Down Expand Up @@ -57,6 +60,9 @@ namespace restinio
// RESTinio uses boost::asio.
#include <boost/asio.hpp>

// Define added to not have to distinguish between boost and non-boost asio in other code.
#define RESTINIO_ASIO_VERSION BOOST_ASIO_VERSION

namespace restinio
{

Expand Down
11 changes: 10 additions & 1 deletion dev/restinio/impl/sendfile_operation_win.ipp
Expand Up @@ -19,7 +19,7 @@ namespace impl
namespace asio_details
{

#if ASIO_VERSION < 101300
#if RESTINIO_ASIO_VERSION < 101300

template<typename Socket >
decltype(auto)
Expand Down Expand Up @@ -138,8 +138,17 @@ class sendfile_operation_runner_t final

private:
std::unique_ptr< char[] > m_buffer{ new char [ this->m_chunk_size ] };
// Starting with asio-1.14.0 (boost-1.70.0) we must use executor_or_context_from_socket
// in order to get the io_context.
#if RESTINIO_ASIO_VERSION >= 101400
asio_ns::windows::random_access_handle
m_file_handle{
asio_details::executor_or_context_from_socket(this->m_socket),
this->m_file_descriptor };
#else
asio_ns::windows::random_access_handle
m_file_handle{ this->m_socket.get_executor().context(), this->m_file_descriptor };
#endif

auto
make_async_read_some_at_handler() noexcept
Expand Down
4 changes: 4 additions & 0 deletions dev/restinio/impl/tls_socket.hpp
Expand Up @@ -38,6 +38,10 @@ class tls_socket_t
public:
using socket_t = asio_ns::ssl::stream< asio_ns::ip::tcp::socket >;
using context_handle_t = std::shared_ptr< asio_ns::ssl::context >;
// Needed for asio >= 1.16.0 (starting with boost-1.72.0)
#if RESTINIO_ASIO_VERSION >= 101600
using executor_type = asio_ns::executor;
#endif
tls_socket_t( const tls_socket_t & ) = delete;
tls_socket_t & operator = ( const tls_socket_t & ) = delete;

Expand Down

0 comments on commit 003b199

Please sign in to comment.