From 780847bf4396ae32308ae6c92986bb18f4587644 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Fri, 1 Feb 2013 09:11:43 -0600 Subject: [PATCH] cleans up handle_accept error paths --- websocketpp/roles/server_endpoint.hpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/websocketpp/roles/server_endpoint.hpp b/websocketpp/roles/server_endpoint.hpp index 083a98e219..227f6df117 100644 --- a/websocketpp/roles/server_endpoint.hpp +++ b/websocketpp/roles/server_endpoint.hpp @@ -96,12 +96,21 @@ public: } void handle_accept(connection_hdl hdl, const lib::error_code& ec) { - connection_ptr con = endpoint_type::get_con_from_hdl(hdl); + lib::error_code hdl_ec; + connection_ptr con = endpoint_type::get_con_from_hdl(hdl,hdl_ec); - if (!con) { - // TODO: should this be considered a server fatal error? - endpoint_type::m_elog.write(log::elevel::warn, + if (hdl_ec == error::bad_connection) { + // The connection we were trying to connect went out of scope + // This really shouldn't happen + endpoint_type::m_elog.write(log::elevel::fatal, "handle_accept got an invalid handle back"); + con->terminate(); + } else if (hdl_ec) { + // There was some other unknown error attempting to convert the hdl + // to a connection. + endpoint_type::m_elog.write(log::elevel::fatal, + "handle_accept error in get_con_from_hdl: "+hdl_ec.message()); + con->terminate(); } else { if (ec) { con->terminate();