Small Websocket cleanups.

This commit is contained in:
David Schwartz
2016-04-11 11:20:23 -07:00
committed by Nik Bougalis
parent 5c5ee6f763
commit dabc5567f7
3 changed files with 10 additions and 10 deletions

View File

@@ -38,7 +38,7 @@ class AutoSocket
public:
using ssl_socket = boost::asio::ssl::stream<boost::asio::ip::tcp::socket>;
using endpoint_type = boost::asio::ip::tcp::socket::endpoint_type;
using socket_ptr = std::shared_ptr<ssl_socket>;
using socket_ptr = std::unique_ptr<ssl_socket>;
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<ssl_socket> (s, c);
mSocket = std::make_unique<ssl_socket> (s, c);
}
AutoSocket (

View File

@@ -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 <WebSocket>::destroy(ptr); });
[p = std::move(ptr)] (Job&)
{
ConnectionImpl <WebSocket>::destroy(std::move (p));
});
}
void message_job(std::string const& name, connection_ptr const& cpClient)

View File

@@ -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<endpoint_type>::handle_shutdown,
&autotls<endpoint_type>::handle_shutdown,
m_socket_ptr,
beast::asio::placeholders::error
)
);
beast::asio::placeholders::error));
if (ignored_ec) {
return false;