mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
moves bad_connection error handling into get_con_from_hdl
This commit is contained in:
@@ -287,10 +287,13 @@ protected:
|
||||
*
|
||||
* @return the connection_ptr. May be NULL if the handle was invalid.
|
||||
*/
|
||||
connection_ptr get_con_from_hdl(connection_hdl hdl) {
|
||||
connection_ptr get_con_from_hdl(connection_hdl hdl, lib::error_code & ec) {
|
||||
scoped_lock_type lock(m_mutex);
|
||||
connection_ptr con = lib::static_pointer_cast<connection_type,void>(
|
||||
hdl.lock());
|
||||
if (!con) {
|
||||
ec = error::make_error_code(error::bad_connection);
|
||||
}
|
||||
return con;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,11 +91,8 @@ template <typename connection, typename config>
|
||||
void endpoint<connection,config>::interrupt(connection_hdl hdl,
|
||||
lib::error_code & ec)
|
||||
{
|
||||
connection_ptr con = get_con_from_hdl(hdl);
|
||||
if (!con) {
|
||||
ec = error::make_error_code(error::bad_connection);
|
||||
return;
|
||||
}
|
||||
connection_ptr con = get_con_from_hdl(hdl,ec);
|
||||
if (ec) {return;}
|
||||
|
||||
m_alog.write(log::alevel::devel,"Interrupting connection"+con.get());
|
||||
|
||||
@@ -113,11 +110,8 @@ template <typename connection, typename config>
|
||||
void endpoint<connection,config>::send(connection_hdl hdl,
|
||||
const std::string& payload, frame::opcode::value op, lib::error_code & ec)
|
||||
{
|
||||
connection_ptr con = get_con_from_hdl(hdl);
|
||||
if (!con) {
|
||||
ec = error::make_error_code(error::bad_connection);
|
||||
return;
|
||||
}
|
||||
connection_ptr con = get_con_from_hdl(hdl,ec);
|
||||
if (ec) {return;}
|
||||
|
||||
ec = con->send(payload,op);
|
||||
}
|
||||
@@ -135,11 +129,9 @@ template <typename connection, typename config>
|
||||
void endpoint<connection,config>::send(connection_hdl hdl, message_ptr msg,
|
||||
lib::error_code & ec)
|
||||
{
|
||||
connection_ptr con = get_con_from_hdl(hdl);
|
||||
if (!con) {
|
||||
ec = error::make_error_code(error::bad_connection);
|
||||
return;
|
||||
}
|
||||
connection_ptr con = get_con_from_hdl(hdl,ec);
|
||||
if (ec) {return;}
|
||||
|
||||
ec = con->send(msg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user