/// Handler callback for start_accept void handle_accept(connection_ptr con, lib::error_code const & ec) { if (ec) { con->terminate(ec); if (ec == error::operation_canceled) { endpoint_type::m_elog.write(log::elevel::info, "handle_accept error: "+ec.message()); } else { endpoint_type::m_elog.write(log::elevel::rerror, "handle_accept error: "+ec.message()); } } else { con->start(); } lib::error_code start_ec; start_accept(start_ec); if (start_ec == error::async_accept_not_listening) { endpoint_type::m_elog.write(log::elevel::info, "Stopping acceptance of new connections because the underlying transport is no longer listening."); } else if (start_ec) { endpoint_type::m_elog.write(log::elevel::rerror, "Restarting async_accept loop failed: "+ec.message()); } }
void handle_accept(connection_hdl hdl, const lib::error_code& ec) { lib::error_code hdl_ec; connection_ptr con = endpoint_type::get_con_from_hdl(hdl,hdl_ec); 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(); endpoint_type::m_elog.write(log::elevel::rerror, "handle_accept error: "+ec.message()); } else { con->start(); } } // TODO: are there cases where we should terminate this loop? start_accept(); }