Skip to content

Commit

Permalink
Fixed Boost 1.70 compatibility to restore macOS compile.
Browse files Browse the repository at this point in the history
Manually applied this patch: zaphoyd/websocketpp#814
  • Loading branch information
clangen committed Jun 17, 2019
1 parent eaca4ea commit 21c28ff
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class connection : public config::socket_type::socket_con_type {
* Called by the endpoint as a connection is being established to provide
* the uri being connected to to the transport layer.
*
* This transport policy doesn't use the uri except to forward it to the
* This transport policy doesn't use the uri except to forward it to the
* socket layer.
*
* @since 0.6.0
Expand Down Expand Up @@ -311,10 +311,10 @@ class connection : public config::socket_type::socket_con_type {
* needed.
*/
timer_ptr set_timer(long duration, timer_handler callback) {
timer_ptr new_timer = lib::make_shared<lib::asio::steady_timer>(
lib::ref(*m_io_service),
lib::asio::milliseconds(duration)
);
timer_ptr new_timer(
new lib::asio::steady_timer(
*m_io_service,
lib::asio::milliseconds(duration)));

if (config::enable_multithreading) {
new_timer->async_wait(m_strand->wrap(lib::bind(
Expand Down Expand Up @@ -375,14 +375,14 @@ class connection : public config::socket_type::socket_con_type {
* Primarily used if you are using mismatched asio / system_error
* implementations such as `boost::asio` with `std::system_error`. In these
* cases the transport error type is different than the library error type
* and some WebSocket++ functions that return transport errors via the
* and some WebSocket++ functions that return transport errors via the
* library error code type will be coerced into a catch all `pass_through`
* or `tls_error` error. This method will return the original machine
* or `tls_error` error. This method will return the original machine
* readable transport error in the native type.
*
* @since 0.7.0
*
* @return Error code indicating the reason the connection was closed or
* @return Error code indicating the reason the connection was closed or
* failed
*/
lib::asio::error_code get_transport_ec() const {
Expand Down Expand Up @@ -461,8 +461,7 @@ class connection : public config::socket_type::socket_con_type {
m_io_service = io_service;

if (config::enable_multithreading) {
m_strand = lib::make_shared<lib::asio::io_service::strand>(
lib::ref(*io_service));
m_strand.reset(new lib::asio::io_service::strand(*io_service));
}

lib::error_code ec = socket_con_type::init_asio(io_service, m_strand,
Expand Down Expand Up @@ -499,7 +498,7 @@ class connection : public config::socket_type::socket_con_type {
}

timer_ptr post_timer;

if (config::timeout_socket_post_init > 0) {
post_timer = set_timer(
config::timeout_socket_post_init,
Expand Down Expand Up @@ -863,9 +862,9 @@ class connection : public config::socket_type::socket_con_type {
lib::placeholders::_1, lib::placeholders::_2
)
)
);
);
}

}

void handle_async_read(read_handler handler, lib::asio::error_code const & ec,
Expand Down Expand Up @@ -1067,7 +1066,7 @@ class connection : public config::socket_type::socket_con_type {
* @param callback The function to call back
* @param ec The status code
*/
void handle_async_shutdown_timeout(timer_ptr, init_handler callback,
void handle_async_shutdown_timeout(timer_ptr, init_handler callback,
lib::error_code const & ec)
{
lib::error_code ret_ec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class endpoint : public config::socket_type {
rhs.m_acceptor = NULL;
rhs.m_listen_backlog = lib::asio::socket_base::max_connections;
rhs.m_state = UNINITIALIZED;
// TODO: this needs to be updated
}
return *this;
Expand Down Expand Up @@ -191,8 +191,7 @@ class endpoint : public config::socket_type {

m_io_service = ptr;
m_external_io_service = true;
m_acceptor = lib::make_shared<lib::asio::ip::tcp::acceptor>(
lib::ref(*m_io_service));
m_acceptor.reset(new lib::asio::ip::tcp::acceptor(*m_io_service));

m_state = READY;
ec = lib::error_code();
Expand Down Expand Up @@ -222,7 +221,7 @@ class endpoint : public config::socket_type {
* @param ec Set to indicate what error occurred, if any.
*/
void init_asio(lib::error_code & ec) {
// Use a smart pointer until the call is successful and ownership has
// Use a smart pointer until the call is successful and ownership has
// successfully been taken. Use unique_ptr when available.
// TODO: remove the use of auto_ptr when C++98/03 support is no longer
// necessary.
Expand All @@ -244,7 +243,7 @@ class endpoint : public config::socket_type {
* @see init_asio(io_service_ptr ptr)
*/
void init_asio() {
// Use a smart pointer until the call is successful and ownership has
// Use a smart pointer until the call is successful and ownership has
// successfully been taken. Use unique_ptr when available.
// TODO: remove the use of auto_ptr when C++98/03 support is no longer
// necessary.
Expand Down Expand Up @@ -357,15 +356,15 @@ class endpoint : public config::socket_type {
lib::asio::io_service & get_io_service() {
return *m_io_service;
}

/// Get local TCP endpoint
/**
* Extracts the local endpoint from the acceptor. This represents the
* address that WebSocket++ is listening on.
*
* Sets a bad_descriptor error if the acceptor is not currently listening
* or otherwise unavailable.
*
*
* @since 0.7.0
*
* @param ec Set to indicate what error occurred, if any.
Expand Down Expand Up @@ -660,9 +659,7 @@ class endpoint : public config::socket_type {
* @since 0.3.0
*/
void start_perpetual() {
m_work = lib::make_shared<lib::asio::io_service::work>(
lib::ref(*m_io_service)
);
m_work.reset(new lib::asio::io_service::work(*m_io_service));
}

/// Clears the endpoint's perpetual flag, allowing it to exit when empty
Expand Down Expand Up @@ -800,7 +797,7 @@ class endpoint : public config::socket_type {
m_elog = e;
}

void handle_accept(accept_handler callback, lib::asio::error_code const &
void handle_accept(accept_handler callback, lib::asio::error_code const &
asio_ec)
{
lib::error_code ret_ec;
Expand All @@ -826,8 +823,7 @@ class endpoint : public config::socket_type {

// Create a resolver
if (!m_resolver) {
m_resolver = lib::make_shared<lib::asio::ip::tcp::resolver>(
lib::ref(*m_io_service));
m_resolver.reset(new lib::asio::ip::tcp::resolver(*m_io_service));
}

tcon->set_uri(u);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ class connection : public lib::enable_shared_from_this<connection> {
return socket::make_error_code(socket::error::invalid_state);
}

m_socket = lib::make_shared<lib::asio::ip::tcp::socket>(
lib::ref(*service));
m_socket.reset(new lib::asio::ip::tcp::socket(*service));

m_state = READY;

Expand Down Expand Up @@ -263,14 +262,14 @@ class connection : public lib::enable_shared_from_this<connection> {

/// Translate any security policy specific information about an error code
/**
* Translate_ec takes an Asio error code and attempts to convert its value
* Translate_ec takes an Asio error code and attempts to convert its value
* to an appropriate websocketpp error code. In the case that the Asio and
* Websocketpp error types are the same (such as using boost::asio and
* boost::system_error or using standalone asio and std::system_error the
* code will be passed through natively.
*
* In the case of a mismatch (boost::asio with std::system_error) a
* translated code will be returned. The plain socket policy does not have
* translated code will be returned. The plain socket policy does not have
* any additional information so all such errors will be reported as the
* generic transport pass_through error.
*
Expand All @@ -284,8 +283,8 @@ class connection : public lib::enable_shared_from_this<connection> {
// We don't know any more information about this error so pass through
return make_error_code(transport::error::pass_through);
}
/// Overload of translate_ec to catch cases where lib::error_code is the

/// Overload of translate_ec to catch cases where lib::error_code is the
/// same type as lib::asio::error_code
lib::error_code translate_ec(lib::error_code ec) {
// We don't know any more information about this error, but the error is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ class connection : public lib::enable_shared_from_this<connection> {
if (!m_context) {
return socket::make_error_code(socket::error::invalid_tls_context);
}
m_socket = lib::make_shared<socket_type>(
_WEBSOCKETPP_REF(*service),lib::ref(*m_context));
m_socket.reset(new socket_type(*service, *m_context));

m_io_service = service;
m_strand = strand;
Expand Down Expand Up @@ -229,7 +228,7 @@ class connection : public lib::enable_shared_from_this<connection> {
* @param callback Handler to call back with completion information
*/
void pre_init(init_handler callback) {
// TODO: is this the best way to check whether this function is
// TODO: is this the best way to check whether this function is
// available in the version of OpenSSL being used?
// TODO: consider case where host is an IP address
#if OPENSSL_VERSION_NUMBER >= 0x90812f
Expand Down Expand Up @@ -368,11 +367,11 @@ class connection : public lib::enable_shared_from_this<connection> {
return make_error_code(transport::error::pass_through);
}
}

/// Overload of translate_ec to catch cases where lib::error_code is the
/// same type as lib::asio::error_code
lib::error_code translate_ec(lib::error_code ec) {
// Normalize the tls_short_read error as it is used by the library and
// Normalize the tls_short_read error as it is used by the library and
// needs a consistent value. All other errors pass through natively.
// TODO: how to get the SSL category from std::error?
/*if (ec.category() == lib::asio::error::get_ssl_category()) {
Expand Down

0 comments on commit 21c28ff

Please sign in to comment.