Skip to content

Commit

Permalink
Fixed shutdown problem in OpenSSL 3
Browse files Browse the repository at this point in the history
  • Loading branch information
TwentyPast4 committed Jan 26, 2023
1 parent c6e1f90 commit aef0a48
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions websocketpp/transport/asio/security/tls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,29 @@ class connection : public lib::enable_shared_from_this<connection> {
}

void async_shutdown(socket::shutdown_handler callback) {
callback = lib::bind(&connection::handle_async_shutdown, this, callback, lib::placeholders::_1);
if (m_strand) {
m_socket->async_shutdown(m_strand->wrap(callback));
} else {
m_socket->async_shutdown(callback);
}
}

void handle_async_shutdown(socket::shutdown_handler callback, lib::asio::error_code const & ec)
{
if (ec == lib::asio::error::operation_aborted)
{
const int shutdownState = SSL_get_shutdown(get_socket().native_handle());
if (shutdownState & SSL_RECEIVED_SHUTDOWN)
{
callback(lib::asio::error_code(lib::asio::error::not_connected, ec.category()));
return;
}
}

callback(ec);
}

public:
/// Translate any security policy specific information about an error code
/**
Expand Down

0 comments on commit aef0a48

Please sign in to comment.