mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
updates interrupt functionality to latest API spec
This commit is contained in:
@@ -46,6 +46,8 @@ typedef lib::function<void(connection_hdl)> open_handler;
|
||||
typedef lib::function<void(connection_hdl)> close_handler;
|
||||
typedef lib::function<void(connection_hdl)> fail_handler;
|
||||
|
||||
typedef lib::function<void(connection_hdl)> interrupt_handler;
|
||||
|
||||
typedef lib::function<void(connection_hdl)> handshake_init_handler;
|
||||
|
||||
typedef lib::function<bool(connection_hdl,std::string)> ping_handler;
|
||||
@@ -215,6 +217,10 @@ public:
|
||||
void set_open_handler(open_handler h) {
|
||||
m_open_handler = h;
|
||||
}
|
||||
|
||||
void set_interrupt_handler(interrupt_handler h) {
|
||||
m_interrupt_handler = h;
|
||||
}
|
||||
|
||||
/// Set new connection handler
|
||||
/**
|
||||
@@ -699,6 +705,7 @@ private:
|
||||
connection_hdl m_connection_hdl;
|
||||
handler_ptr m_handler;
|
||||
open_handler m_open_handler;
|
||||
interrupt_handler m_interrupt_handler;
|
||||
|
||||
/// External connection state
|
||||
/**
|
||||
|
||||
@@ -101,30 +101,21 @@ public:
|
||||
void set_open_handler(open_handler h) {
|
||||
m_open_handler = h;
|
||||
}
|
||||
void set_interrupt_handler(interrupt_handler h) {
|
||||
m_interrupt_handler = h;
|
||||
}
|
||||
|
||||
void interrupt(connection_hdl hdl, lib::error_code & ec) {
|
||||
|
||||
std::cout << "Interrupting connection " << &hdl << std::endl;
|
||||
|
||||
/*lib::shared_ptr<void> s(hdl->lock());
|
||||
|
||||
if (!s) {
|
||||
std::cout << "bad weak pointer in interrupt" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
connection_ptr con = lib::static_pointer_cast<connection_type, void>(hdl)->lock();*/
|
||||
connection_ptr con = lib::static_pointer_cast<connection_type, void>(hdl.lock());
|
||||
connection_ptr con = get_con_from_hdl(hdl);
|
||||
|
||||
if (!con) {
|
||||
ec = error::make_error_code(error::bad_connection);
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "CALL con->interrupt() HERE!!" << std::endl;
|
||||
ec = con->interrupt();
|
||||
std::cout << "Interrupting connection " << con.get() << std::endl;
|
||||
|
||||
//ec = lib::error_code();
|
||||
ec = con->interrupt();
|
||||
}
|
||||
|
||||
void interrupt(connection_hdl hdl) {
|
||||
@@ -160,6 +151,7 @@ private:
|
||||
std::string m_user_agent;
|
||||
|
||||
open_handler m_open_handler;
|
||||
interrupt_handler m_interrupt_handler;
|
||||
|
||||
// endpoint resources
|
||||
std::set<connection_ptr> m_connections;
|
||||
|
||||
@@ -256,19 +256,21 @@ void connection<config>::close(const close::status::value code,
|
||||
template <typename config>
|
||||
lib::error_code connection<config>::interrupt() {
|
||||
std::cout << "connection::interrupt" << std::endl;
|
||||
/*return transport_type::inturrupt(
|
||||
return transport_type::interrupt(
|
||||
lib::bind(
|
||||
&type::handle_inturrupt,
|
||||
&type::handle_interrupt,
|
||||
type::shared_from_this()
|
||||
)
|
||||
);*/
|
||||
);
|
||||
return lib::error_code();
|
||||
}
|
||||
|
||||
|
||||
template <typename config>
|
||||
void connection<config>::handle_interrupt() {
|
||||
m_handler->on_interrupt(type::shared_from_this());
|
||||
if (m_interrupt_handler) {
|
||||
m_interrupt_handler(m_connection_hdl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,9 +54,14 @@ endpoint<connection,config>::create_connection() {
|
||||
|
||||
//
|
||||
con->set_handle(w);
|
||||
con->set_handler(m_default_handler);
|
||||
|
||||
con->set_handler(m_default_handler);
|
||||
|
||||
// Copy default handlers from the endpoint
|
||||
con->set_open_handler(m_open_handler);
|
||||
con->set_termination_handler(
|
||||
con->set_interrupt_handler(m_interrupt_handler);
|
||||
|
||||
con->set_termination_handler(
|
||||
lib::bind(
|
||||
&type::remove_connection,
|
||||
this,
|
||||
|
||||
@@ -237,7 +237,7 @@ protected:
|
||||
m_connection_hdl = hdl;
|
||||
}
|
||||
|
||||
lib::error_code inturrupt(inturrupt_handler handler) {
|
||||
lib::error_code interrupt(inturrupt_handler handler) {
|
||||
// strand post handle_inturrupt
|
||||
/*m_strand->post(lib::bind(
|
||||
&type::handle_inturrupt,
|
||||
@@ -255,9 +255,9 @@ protected:
|
||||
return lib::error_code();
|
||||
}
|
||||
|
||||
void handle_inturrupt(inturrupt_handler handler) {
|
||||
/*void handle_inturrupt(inturrupt_handler handler) {
|
||||
handler();
|
||||
}
|
||||
}*/
|
||||
|
||||
/// close and clean up the underlying socket
|
||||
void shutdown() {
|
||||
|
||||
Reference in New Issue
Block a user