From 3d0d28affcaad612c1ec21fef6ae55bf0d16c338 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Thu, 10 Oct 2013 13:45:49 -0500 Subject: [PATCH] Eliminate spurious expired timers in certain error conditions references #295 --- changelog.md | 2 ++ websocketpp/impl/connection_impl.hpp | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/changelog.md b/changelog.md index 04adfe3f57..d538bc3097 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,6 @@ HEAD +- Eliminates spurious expired timers in certain error conditions. Thank you + Banaan for reporting. #295 - Consolidates all bundled library licenses into the COPYING file. - Updates bundled sha1 library to one with a cleaner interface and more straight-forward license. diff --git a/websocketpp/impl/connection_impl.hpp b/websocketpp/impl/connection_impl.hpp index 7dde35a831..5468a72ab5 100644 --- a/websocketpp/impl/connection_impl.hpp +++ b/websocketpp/impl/connection_impl.hpp @@ -1177,6 +1177,11 @@ void connection::handle_send_http_response( this->log_open_result(); + if (m_handshake_timer) { + m_handshake_timer->cancel(); + m_handshake_timer.reset(); + } + if (m_response.get_status_code() != http::status_code::switching_protocols) { if (m_processor) { @@ -1193,11 +1198,6 @@ void connection::handle_send_http_response( return; } - if (m_handshake_timer) { - m_handshake_timer->cancel(); - m_handshake_timer.reset(); - } - this->atomic_state_change( istate::PROCESS_HTTP_REQUEST, istate::PROCESS_CONNECTION, @@ -1339,6 +1339,11 @@ void connection::handle_read_http_response(const lib::error_code& ec, m_alog.write(log::alevel::devel,std::string("Raw response: ")+m_response.raw()); if (m_response.headers_ready()) { + if (m_handshake_timer) { + m_handshake_timer->cancel(); + m_handshake_timer.reset(); + } + lib::error_code ec = m_processor->validate_server_handshake_response( m_request, m_response @@ -1361,11 +1366,6 @@ void connection::handle_read_http_response(const lib::error_code& ec, "handle_read_http_response must be called from READ_HTTP_RESPONSE state" ); - if (m_handshake_timer) { - m_handshake_timer->cancel(); - m_handshake_timer.reset(); - } - this->log_open_result(); if (m_open_handler) {