diff --git a/source/corvusoft/restbed/detail/http_impl.cpp b/source/corvusoft/restbed/detail/http_impl.cpp index 77f918a..08d2c9c 100644 --- a/source/corvusoft/restbed/detail/http_impl.cpp +++ b/source/corvusoft/restbed/detail/http_impl.cpp @@ -153,7 +153,7 @@ namespace restbed { #endif auto socket = make_shared< tcp::socket >( *request->m_pimpl->m_io_service ); - request->m_pimpl->m_socket = make_shared< SocketImpl >( socket ); + request->m_pimpl->m_socket = make_shared< SocketImpl >( *request->m_pimpl->m_io_service, socket ); #ifdef BUILD_SSL } @@ -196,7 +196,7 @@ namespace restbed } socket->set_verify_callback( asio::ssl::rfc2818_verification( request->get_host( ) ) ); - request->m_pimpl->m_socket = make_shared< SocketImpl >( socket ); + request->m_pimpl->m_socket = make_shared< SocketImpl >( *request->m_pimpl->m_io_service, socket ); } #endif void HttpImpl::request_handler( const error_code& error, const shared_ptr< Request >& request, const function< void ( const shared_ptr< Request >, const shared_ptr< Response > ) >& callback ) diff --git a/source/corvusoft/restbed/detail/service_impl.cpp b/source/corvusoft/restbed/detail/service_impl.cpp index 6772af1..87be1ce 100644 --- a/source/corvusoft/restbed/detail/service_impl.cpp +++ b/source/corvusoft/restbed/detail/service_impl.cpp @@ -147,7 +147,7 @@ namespace restbed void ServiceImpl::http_listen( void ) const { - auto socket = make_shared< tcp::socket >( m_acceptor->get_io_service( ) ); + auto socket = make_shared< tcp::socket >( *m_io_service ); m_acceptor->async_accept( *socket, bind( &ServiceImpl::create_session, this, socket, _1 ) ); } @@ -273,7 +273,7 @@ namespace restbed void ServiceImpl::https_listen( void ) const { - auto socket = make_shared< asio::ssl::stream< tcp::socket > >( m_ssl_acceptor->get_io_service( ), *m_ssl_context ); + auto socket = make_shared< asio::ssl::stream< tcp::socket > >( *m_io_service, *m_ssl_context ); m_ssl_acceptor->async_accept( socket->lowest_layer( ), bind( &ServiceImpl::create_ssl_session, this, socket, _1 ) ); } @@ -289,7 +289,7 @@ namespace restbed return; } - auto connection = make_shared< SocketImpl >( socket, m_logger ); + auto connection = make_shared< SocketImpl >( *m_io_service, socket, m_logger ); connection->set_timeout( m_settings->get_connection_timeout( ) ); if (m_settings->get_keep_alive()) { connection->set_keep_alive( m_settings->get_keep_alive_start(), @@ -530,7 +530,7 @@ namespace restbed { if ( not error ) { - auto connection = make_shared< SocketImpl >( socket, m_logger ); + auto connection = make_shared< SocketImpl >( *m_io_service, socket, m_logger ); connection->set_timeout( m_settings->get_connection_timeout( ) ); if (m_settings->get_keep_alive()) { connection->set_keep_alive( m_settings->get_keep_alive_start(), diff --git a/source/corvusoft/restbed/detail/socket_impl.cpp b/source/corvusoft/restbed/detail/socket_impl.cpp index fac0082..942eefa 100644 --- a/source/corvusoft/restbed/detail/socket_impl.cpp +++ b/source/corvusoft/restbed/detail/socket_impl.cpp @@ -49,12 +49,12 @@ namespace restbed { namespace detail { - SocketImpl::SocketImpl( const shared_ptr< tcp::socket >& socket, const shared_ptr< Logger >& logger ) : m_error_handler( nullptr ), + SocketImpl::SocketImpl( asio::io_context& context, const shared_ptr< tcp::socket >& socket, const shared_ptr< Logger >& logger ) : m_error_handler( nullptr ), m_is_open( socket->is_open( ) ), m_pending_writes( ), m_logger( logger ), m_timeout( 0 ), - m_io_service( socket->get_io_service( ) ), + m_io_service( context ), m_timer( make_shared< asio::steady_timer >( m_io_service ) ), m_strand( make_shared< io_service::strand > ( m_io_service ) ), m_resolver( nullptr ), @@ -66,12 +66,12 @@ namespace restbed return; } #ifdef BUILD_SSL - SocketImpl::SocketImpl( const shared_ptr< asio::ssl::stream< tcp::socket > >& socket, const shared_ptr< Logger >& logger ) : m_error_handler( nullptr ), + SocketImpl::SocketImpl( asio::io_context& context, const shared_ptr< asio::ssl::stream< tcp::socket > >& socket, const shared_ptr< Logger >& logger ) : m_error_handler( nullptr ), m_is_open( socket->lowest_layer( ).is_open( ) ), m_pending_writes( ), m_logger( logger ), m_timeout( 0 ), - m_io_service( socket->get_io_service( ) ), + m_io_service( context ), m_timer( make_shared< asio::steady_timer >( m_io_service ) ), m_strand( make_shared< io_service::strand > ( m_io_service ) ), m_resolver( nullptr ), diff --git a/source/corvusoft/restbed/detail/socket_impl.hpp b/source/corvusoft/restbed/detail/socket_impl.hpp index 41aec42..0977eba 100644 --- a/source/corvusoft/restbed/detail/socket_impl.hpp +++ b/source/corvusoft/restbed/detail/socket_impl.hpp @@ -53,9 +53,9 @@ namespace restbed //Definitions //Constructors - SocketImpl( const std::shared_ptr< asio::ip::tcp::socket >& socket, const std::shared_ptr< Logger >& logger = nullptr ); + SocketImpl( asio::io_context& context, const std::shared_ptr< asio::ip::tcp::socket >& socket, const std::shared_ptr< Logger >& logger = nullptr ); #ifdef BUILD_SSL - SocketImpl( const std::shared_ptr< asio::ssl::stream< asio::ip::tcp::socket > >& socket, const std::shared_ptr< Logger >& logger = nullptr ); + SocketImpl( asio::io_context& context, const std::shared_ptr< asio::ssl::stream< asio::ip::tcp::socket > >& socket, const std::shared_ptr< Logger >& logger = nullptr ); #endif ~SocketImpl( void ) = default;