From dabc5567f726dbb689d3d135c9fdb4fdb2a95e62 Mon Sep 17 00:00:00 2001 From: David Schwartz Date: Mon, 11 Apr 2016 11:20:23 -0700 Subject: [PATCH] Small Websocket cleanups. --- src/ripple/websocket/AutoSocket.h | 4 ++-- src/ripple/websocket/Handler.h | 7 +++++-- src/websocketpp_02/src/sockets/autotls.hpp | 9 +++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ripple/websocket/AutoSocket.h b/src/ripple/websocket/AutoSocket.h index 3c13accdd..6d10246e4 100644 --- a/src/ripple/websocket/AutoSocket.h +++ b/src/ripple/websocket/AutoSocket.h @@ -38,7 +38,7 @@ class AutoSocket public: using ssl_socket = boost::asio::ssl::stream; using endpoint_type = boost::asio::ip::tcp::socket::endpoint_type; - using socket_ptr = std::shared_ptr; + using socket_ptr = std::unique_ptr; using plain_socket = ssl_socket::next_layer_type; using lowest_layer_type = ssl_socket::lowest_layer_type; using handshake_type = ssl_socket::handshake_type; @@ -55,7 +55,7 @@ public: , mBuffer ((plainOnly || secureOnly) ? 0 : 4) , j_ (ripple::debugJournal()) { - mSocket = std::make_shared (s, c); + mSocket = std::make_unique (s, c); } AutoSocket ( diff --git a/src/ripple/websocket/Handler.h b/src/ripple/websocket/Handler.h index 6391b2456..4bd4e3c0d 100644 --- a/src/ripple/websocket/Handler.h +++ b/src/ripple/websocket/Handler.h @@ -278,7 +278,7 @@ public: return; } - ptr = it->second; + ptr = std::move (it->second); // prevent the ConnectionImpl from being destroyed until we release // the lock mMap.erase (it); @@ -298,7 +298,10 @@ public: app_.getJobQueue ().addJob ( jtCLIENT, "WSClient::destroy", - [ptr] (Job&) { ConnectionImpl ::destroy(ptr); }); + [p = std::move(ptr)] (Job&) + { + ConnectionImpl ::destroy(std::move (p)); + }); } void message_job(std::string const& name, connection_ptr const& cpClient) diff --git a/src/websocketpp_02/src/sockets/autotls.hpp b/src/websocketpp_02/src/sockets/autotls.hpp index f0ae9fbb7..c18de9115 100644 --- a/src/websocketpp_02/src/sockets/autotls.hpp +++ b/src/websocketpp_02/src/sockets/autotls.hpp @@ -133,18 +133,15 @@ public: callback(error); } - // note, this function for some reason shouldn't/doesn't need to be - // called for plain HTTP connections. not sure why. + // Only SSL conections actually need to be shut down bool shutdown() { boost::system::error_code ignored_ec; m_socket_ptr->async_shutdown( // Don't block on connection shutdown DJS std::bind( - &autotls::handle_shutdown, + &autotls::handle_shutdown, m_socket_ptr, - beast::asio::placeholders::error - ) - ); + beast::asio::placeholders::error)); if (ignored_ec) { return false;