diff --git a/dev/restinio/asio_include.hpp b/dev/restinio/asio_include.hpp index 194daf14..108ec782 100644 --- a/dev/restinio/asio_include.hpp +++ b/dev/restinio/asio_include.hpp @@ -13,6 +13,9 @@ // RESTinio uses stand-alone version of asio. #include +// 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; @@ -57,6 +60,9 @@ namespace restinio // RESTinio uses boost::asio. #include +// 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 { diff --git a/dev/restinio/impl/sendfile_operation_win.ipp b/dev/restinio/impl/sendfile_operation_win.ipp index 387a1e07..ec0d8b70 100644 --- a/dev/restinio/impl/sendfile_operation_win.ipp +++ b/dev/restinio/impl/sendfile_operation_win.ipp @@ -19,7 +19,7 @@ namespace impl namespace asio_details { -#if ASIO_VERSION < 101300 +#if RESTINIO_ASIO_VERSION < 101300 template decltype(auto) @@ -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 diff --git a/dev/restinio/impl/tls_socket.hpp b/dev/restinio/impl/tls_socket.hpp index 8dd1052a..5e5a3d6d 100644 --- a/dev/restinio/impl/tls_socket.hpp +++ b/dev/restinio/impl/tls_socket.hpp @@ -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;