diff --git a/src/websocketpp_02/src/connection.hpp b/src/websocketpp_02/src/connection.hpp index a03a88a6e..df97c384e 100644 --- a/src/websocketpp_02/src/connection.hpp +++ b/src/websocketpp_02/src/connection.hpp @@ -1404,6 +1404,8 @@ public: log_close_result(); } + else + m_state = session::state::CLOSED; // finally remove this connection from the endpoint's list. This will // remove the last shared pointer to the connection held by WS++. If we diff --git a/src/websocketpp_02/src/roles/server.hpp b/src/websocketpp_02/src/roles/server.hpp index 83858f03c..ea37fc9b2 100644 --- a/src/websocketpp_02/src/roles/server.hpp +++ b/src/websocketpp_02/src/roles/server.hpp @@ -914,7 +914,8 @@ void server::connection::handle_write_response( return; } - if (m_response.get_status_code() != http::status_code::SWITCHING_PROTOCOLS) { + if (m_response.get_status_code() != http::status_code::SWITCHING_PROTOCOLS || + m_connection.m_state == session::state::CLOSED) { if (m_version == -1) { // if this was not a websocket connection, we have written // the expected response and the connection can be closed.