diff --git a/websocketpp/connection.hpp b/websocketpp/connection.hpp index 0a616a3f72..d2ce8fa423 100644 --- a/websocketpp/connection.hpp +++ b/websocketpp/connection.hpp @@ -167,6 +167,7 @@ public: , m_internal_state(session::internal_state::USER_INIT) , m_msg_manager(new con_msg_manager_type()) , m_send_buffer_size(0) + , m_temp_lock(false) , m_is_server(is_server) , m_alog(alog) , m_elog(elog) @@ -860,6 +861,7 @@ private: * Lock m_write_lock */ std::vector m_send_buffer; + bool m_temp_lock; // connection data request_type m_request; diff --git a/websocketpp/impl/connection_impl.hpp b/websocketpp/impl/connection_impl.hpp index 8474a34eb4..f732db0255 100644 --- a/websocketpp/impl/connection_impl.hpp +++ b/websocketpp/impl/connection_impl.hpp @@ -1032,6 +1032,12 @@ void connection::write_frame() { { scoped_lock_type lock(m_write_lock); + if (m_temp_lock) { + return; + } else { + m_temp_lock = true; + } + if (m_send_queue.empty()) { return; } @@ -1096,6 +1102,8 @@ void connection::handle_write_frame(bool terminate, scoped_lock_type lock(m_write_lock); needs_writing = !m_send_queue.empty(); + + m_temp_lock = false; } if (needs_writing) {