Tidy up ssl_stream (experimental):

fix #1323, close #1328

* Fix whitespace
* Remove ssl::context pointer
* Use implicit move ctor and assignment operator
This commit is contained in:
Brett Robinson
2018-11-25 03:55:36 -07:00
committed by Vinnie Falco
parent 69f3e4d8fb
commit eb588ff82c
2 changed files with 5 additions and 20 deletions

View File

@ -2,6 +2,8 @@ Version 194:
* http::async_read returns the right byte count on error * http::async_read returns the right byte count on error
* Add net namespace alias * Add net namespace alias
* Don't use-after-free in test
* Tidy up ssl_stream (experimental)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -72,7 +72,6 @@ class ssl_stream
using stream_type = boost::beast::flat_stream<ssl_stream_type>; using stream_type = boost::beast::flat_stream<ssl_stream_type>;
std::unique_ptr<stream_type> p_; std::unique_ptr<stream_type> p_;
boost::asio::ssl::context* ctx_;
public: public:
/// The native handle type of the SSL stream. /// The native handle type of the SSL stream.
@ -106,25 +105,9 @@ public:
boost::asio::ssl::context& ctx) boost::asio::ssl::context& ctx)
: p_(new stream_type{ : p_(new stream_type{
std::forward<Arg>(arg), ctx}) std::forward<Arg>(arg), ctx})
, ctx_(&ctx)
{ {
} }
/// Move Constructor
ssl_stream(ssl_stream&& other)
: p_(std::move(other.p_))
, ctx_(other.ctx_)
{
}
/// Move Assignment
ssl_stream& operator=(ssl_stream&& other)
{
p_ = std::move(other.p_);
ctx_ = other.ctx_;
return *this;
}
/** Get the executor associated with the object. /** Get the executor associated with the object.
This function may be used to obtain the executor object that the stream This function may be used to obtain the executor object that the stream
@ -476,7 +459,7 @@ public:
*/ */
template<class ConstBufferSequence, class BufferedHandshakeHandler> template<class ConstBufferSequence, class BufferedHandshakeHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(BufferedHandshakeHandler, BOOST_ASIO_INITFN_RESULT_TYPE(BufferedHandshakeHandler,
void (boost::system::error_code, std::size_t)) void(boost::system::error_code, std::size_t))
async_handshake(handshake_type type, ConstBufferSequence const& buffers, async_handshake(handshake_type type, ConstBufferSequence const& buffers,
BOOST_ASIO_MOVE_ARG(BufferedHandshakeHandler) handler) BOOST_ASIO_MOVE_ARG(BufferedHandshakeHandler) handler)
{ {
@ -524,7 +507,7 @@ public:
*/ */
template<class ShutdownHandler> template<class ShutdownHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(ShutdownHandler, BOOST_ASIO_INITFN_RESULT_TYPE(ShutdownHandler,
void (boost::system::error_code)) void(boost::system::error_code))
async_shutdown(BOOST_ASIO_MOVE_ARG(ShutdownHandler) handler) async_shutdown(BOOST_ASIO_MOVE_ARG(ShutdownHandler) handler)
{ {
return p_->next_layer().async_shutdown( return p_->next_layer().async_shutdown(
@ -603,7 +586,7 @@ public:
*/ */
template<class ConstBufferSequence, class WriteHandler> template<class ConstBufferSequence, class WriteHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler, BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t)) void(boost::system::error_code, std::size_t))
async_write_some(ConstBufferSequence const& buffers, async_write_some(ConstBufferSequence const& buffers,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler) BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{ {