diff --git a/src/cpp/ripple/WSHandler.h b/src/cpp/ripple/WSHandler.h index 4324e7bfc..04dadefd3 100644 --- a/src/cpp/ripple/WSHandler.h +++ b/src/cpp/ripple/WSHandler.h @@ -11,14 +11,17 @@ extern void initSSLContext(boost::asio::ssl::context& context, template class WSConnection; +// CAUTION: on_* functions are called by the websocket code while holding a lock + // A single instance of this object is made. // This instance dispatches all events. There is no per connection persistence. template class WSServerHandler : public endpoint_type::handler { public: - typedef typename endpoint_type::handler::connection_ptr connection_ptr; - typedef typename endpoint_type::handler::message_ptr message_ptr; + typedef typename endpoint_type::handler::connection_ptr connection_ptr; + typedef typename endpoint_type::handler::message_ptr message_ptr; + typedef boost::shared_ptr< WSConnection > wsc_ptr; // Private reasons to close. enum { @@ -83,7 +86,6 @@ public: void pingTimer(connection_ptr cpClient) { - typedef boost::shared_ptr< WSConnection > wsc_ptr; wsc_ptr ptr; { boost::mutex::scoped_lock sl(mMapLock); @@ -105,8 +107,6 @@ public: void on_send_empty(connection_ptr cpClient) { - typedef boost::shared_ptr< WSConnection > wsc_ptr; - wsc_ptr ptr; { boost::mutex::scoped_lock sl(mMapLock); @@ -128,8 +128,6 @@ public: void on_pong(connection_ptr cpClient, std::string) { - cLog(lsTRACE) << "Pong received"; - typedef boost::shared_ptr< WSConnection > wsc_ptr; wsc_ptr ptr; { boost::mutex::scoped_lock sl(mMapLock); @@ -143,7 +141,6 @@ public: void on_close(connection_ptr cpClient) { // we cannot destroy the connection while holding the map lock or we deadlock with pubLedger - typedef boost::shared_ptr< WSConnection > wsc_ptr; wsc_ptr ptr; { boost::mutex::scoped_lock sl(mMapLock); @@ -156,7 +153,8 @@ public: ptr->preDestroy(); // Must be done before we return // Must be done without holding the websocket send lock - theApp->getAuxService().post(boost::bind(&WSConnection::destroy, ptr)); + theApp->getJobQueue().addJob(jtCLIENT, + boost::bind(&WSConnection::destroy, ptr)); } void on_message(connection_ptr cpClient, message_ptr mpMessage) diff --git a/src/cpp/websocketpp/src/connection.hpp b/src/cpp/websocketpp/src/connection.hpp index 50a71b58c..ed1b67bb8 100644 --- a/src/cpp/websocketpp/src/connection.hpp +++ b/src/cpp/websocketpp/src/connection.hpp @@ -894,7 +894,8 @@ public: // try and read more if (m_state != session::state::CLOSED && - m_processor->get_bytes_needed() > 0 && + m_processor && + m_processor->get_bytes_needed() > 0 && // FIXME: m_processor had been reset here !m_protocol_error) { // TODO: read timeout timer? diff --git a/src/cpp/websocketpp/src/roles/server.hpp b/src/cpp/websocketpp/src/roles/server.hpp index 969eb3109..7f1758f01 100644 --- a/src/cpp/websocketpp/src/roles/server.hpp +++ b/src/cpp/websocketpp/src/roles/server.hpp @@ -591,7 +591,7 @@ void server::connection::handle_read_request( m_version = -1; shared_const_buffer buffer(reply); m_connection.get_socket().async_write( - buffer, + shared_const_buffer(reply), boost::bind( &type::handle_write_response, m_connection.shared_from_this(), diff --git a/src/cpp/websocketpp/src/sockets/autotls.hpp b/src/cpp/websocketpp/src/sockets/autotls.hpp index cdbe0632b..8ab2bca94 100644 --- a/src/cpp/websocketpp/src/sockets/autotls.hpp +++ b/src/cpp/websocketpp/src/sockets/autotls.hpp @@ -73,7 +73,7 @@ public: } } - // TLS policy adds the on_autotls_init method to the handler to allow the user + // TLS policy adds the on_tls_init method to the handler to allow the user // to set up their asio TLS context. class handler_interface { public: