From ed9d861545b8598134e09ec3197d3313c3b15fea Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 27 Mar 2019 09:13:32 -0700 Subject: [PATCH] Fix ssl_stream teardown --- CHANGELOG.md | 6 +++ include/boost/beast/ssl/ssl_stream.hpp | 62 +++++++++++++------------- 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c31d5a8..91d5380f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 240: + +* Fix ssl_stream teardown + +-------------------------------------------------------------------------------- + Version 239: * More split compilation in HTTP diff --git a/include/boost/beast/ssl/ssl_stream.hpp b/include/boost/beast/ssl/ssl_stream.hpp index 389320dd..b96dbdda 100644 --- a/include/boost/beast/ssl/ssl_stream.hpp +++ b/include/boost/beast/ssl/ssl_stream.hpp @@ -644,38 +644,40 @@ public: return p_->async_read_some(buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } + + // These hooks are used to inform boost::beast::websocket::stream on + // how to tear down the connection as part of the WebSocket + // protocol specifications + #if ! BOOST_BEAST_DOXYGEN + template + friend + void + teardown( + boost::beast::role_type role, + ssl_stream& stream, + boost::system::error_code& ec) + { + // Just forward it to the underlying ssl::stream + using boost::beast::websocket::teardown; + teardown(role, *stream.p_, ec); + } + + template + friend + void + async_teardown( + boost::beast::role_type role, + ssl_stream& stream, + TeardownHandler&& handler) + { + // Just forward it to the underlying ssl::stream + using boost::beast::websocket::async_teardown; + async_teardown(role, *stream.p_, + std::forward(handler)); + } + #endif }; -// These hooks are used to inform boost::beast::websocket::stream on -// how to tear down the connection as part of the WebSocket -// protocol specifications -#if ! BOOST_BEAST_DOXYGEN -template -void -teardown( - boost::beast::role_type role, - ssl_stream& stream, - boost::system::error_code& ec) -{ - // Just forward it to the wrapped stream - using boost::beast::websocket::teardown; - teardown(role, stream.next_layer(), ec); -} - -template -void -async_teardown( - boost::beast::role_type role, - ssl_stream& stream, - TeardownHandler&& handler) -{ - // Just forward it to the wrapped stream - using boost::beast::websocket::async_teardown; - async_teardown(role, - stream.next_layer(), std::forward(handler)); -} -#endif - } // beast } // boost